Blogger Images Compression using WebP

Blogger Images Compression using WebP

I hope you can find this helpful.

you can use this javascript code to convert blogger images to webp.

// image optimization 

var myIMG = document.getElementsByTagName(img);

for (var x =0 ; x < myIMG.length; x++) {
 var imgSRC = myIMG[x].src; 
var imgSRC_width = myIMG[x].width; 
var imgSRC_height = myIMG[x].height; 

   var  mypin = String(imgSRC.match(//s72-c//));
                        imgSRC = replaceAll(imgSRC, mypin, /w + imgSRC_width + -h + imgSRC_height + -p/ + -rw);
imgSRC = imgSRC.replace(/png/gim,webp);
imgSRC = imgSRC.replace(/jpeg/gim,webp);
imgSRC = imgSRC.replace(/jpg/gim,webp);
myIMG[x].src= imgSRC;

console.log(imgSRC);}

This code gets all images in your blog and converts them to webp.

Have fun!

Blogger Images Compression using WebP

Leave a Reply

Your email address will not be published.