Is there a less hacky way to prefetch external favicons and have fallback favicons?
Unanswered
English Angora posted this in #help-forum
English AngoraOP
So I have this feature in my website where you can hover over links and be shown a tooltip containing the domain of the link and the favicon asociated with it.
You can see it in action here if you hover over the chips (on a desktop computer):
https://mark-valentino.vercel.app/project/Cities%20Recommender
Here is the code portion I need help with:
https://github.com/M-Valentino/M-Valentino_Node/blob/main/src/components/smartLink/ExternalLink.jsx
What it does is it first assumes there is a favicon in the website's root directory and if not, loads a favicon from Google. It does this because Google favicons are limited to 16x16px and are almost always going to be of lesser quality. In order to not have a delay in loading the favicons, I loaded them into 0.1x0.1 pixel images so the images go into cache. 0x0px images don't seem to allow prefetching on Firefox.
I don't want to store a collection of favicons for each URL on my site by the way.
You can see it in action here if you hover over the chips (on a desktop computer):
https://mark-valentino.vercel.app/project/Cities%20Recommender
Here is the code portion I need help with:
https://github.com/M-Valentino/M-Valentino_Node/blob/main/src/components/smartLink/ExternalLink.jsx
What it does is it first assumes there is a favicon in the website's root directory and if not, loads a favicon from Google. It does this because Google favicons are limited to 16x16px and are almost always going to be of lesser quality. In order to not have a delay in loading the favicons, I loaded them into 0.1x0.1 pixel images so the images go into cache. 0x0px images don't seem to allow prefetching on Firefox.
I don't want to store a collection of favicons for each URL on my site by the way.
1 Reply
English AngoraOP
I also don't want the console printing errors either. I'm thinking I might have to get a backend running in express with a crawler and a connection to an S3 bucket. I want to avoid that if possible but I'm thinking its the best practice