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);}
Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.