Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache top site favicons #89

Open
sharon-wang opened this issue Dec 21, 2020 · 0 comments
Open

Cache top site favicons #89

sharon-wang opened this issue Dec 21, 2020 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@sharon-wang
Copy link
Member

In #54, we decided to lazy load favicons to avoid bad image loading UX. However, an additional enhancement would be to cache the favicon images so that we don't need to load them every time we visit a site.


Suggested by @vezwork in #54 (comment):

We can do image serialization (for caching) using FileReader.readAsDataURL() along with the fetch API:

async function loadImageToDataURL(url) 
  const response = await fetch(url);
  const blob = await response.blob();
  return new Promise((resolve, reject) => {
    const reader = new FileReader()
    reader.onloadend = () => resolve(reader.result);
    reader.onerror = () => reject();
    reader.readAsDataURL(blob);
  });
}

reference: https://stackoverflow.com/a/20285053/5425899 "How can I convert an image into Base64 string using JavaScript?"

@sharon-wang sharon-wang added the enhancement New feature or request label Dec 21, 2020
@sharon-wang sharon-wang added the good first issue Good for newcomers label Apr 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant