Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are "data URLs" a good way to improve favicon loading speeds?

Tags:

While working in my own website, I'm facing a delay loading time (based on waterflow) for my site's favicon. I tried lots of way to reduce to waterflow delay but failed to manage it. After spending over 3 hours, I've figure out this solution which solve the problem like magic!!

Step 1: Convert favicon into a data-URI ( you can create it from here ) Step 2: Replace your existing favicon with the following code ( use it in function.php or child function)

function add_favicon() {
	echo '<link rel="shortcut icon" type="image/x-icon" href="data:image/x-icon;base64,AAABAAEAICAAAAAAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAgBAAAAAAAAAAAAAAAAAAAAA.......=" />';
}

add_action('wp_head', 'add_favicon');
like image 798
Magnetic WP Avatar asked Oct 16 '18 03:10

Magnetic WP


1 Answers

It`s effective for the icon but it reduces a little when you used image formate like jpg png etc. Buts still its good solution for optimization.

like image 176
Shakil Hossain Avatar answered Oct 11 '22 16:10

Shakil Hossain