Favicon size detection for responsive icons

Favicons can be displayed as 16x16, 32x32, 48x48, 64x64 .

For dynamic favicons , I'm wondering if there is a way to detect favicon sizes, or at least a link showing which browsers are using the sizes. Google draws a space.

+3


source to share


1 answer


Do you want to get the dimensions of the image? try something like this



var el = document.querySelector('link[rel="shortcut icon"],link[rel="icon"]');
var url = el.href || "/favicon.ico"
var image = new Image();
image.src = url;
image.onload = function(){
    alert(image.width + " , " + image.height);
};

      

0


source







All Articles