How does Google’s Page Speed lossless image compression work?

If you’re really interested in the technical details, check out the source code: png_optimizer.cc jpeg_optimizer.cc webp_optimizer.cc For PNG files, they use OptiPNG with some trial-and-error approach // we use these four combinations because different images seem to benefit from // different parameters and this combination of 4 seems to work best for a large // … Read more

CSS delivery optimization: How to defer css loading?

If you don’t mind using jQuery, here is a simple code snippet to help you out. (Otherwise comment and I’ll write a pure-js example function loadStyleSheet(src) { if (document.createStyleSheet){ document.createStyleSheet(src); } else { $(“head”).append($(“<link rel=”stylesheet” href=””+src+” />”)); } }; Just call this in your $(document).ready() or window.onload function and you”re good to go. For #2, … Read more

How to reduce the image size without losing quality in PHP [closed]

If you are looking to reduce the size using coding itself, you can follow this code in php. <?php function compress($source, $destination, $quality) { $info = getimagesize($source); if ($info[‘mime’] == ‘image/jpeg’) $image = imagecreatefromjpeg($source); elseif ($info[‘mime’] == ‘image/gif’) $image = imagecreatefromgif($source); elseif ($info[‘mime’] == ‘image/png’) $image = imagecreatefrompng($source); imagejpeg($image, $destination, $quality); return $destination; } $source_img … Read more