How to Get 100/100 Google Page Speed Score with Middleman and Nginx
Google Page Speed is an awful tool. For example, it often advices to compress images and even suggests to download &quot;optimally&quot; compressed versions. Those images have awful quality, and have visible compression artifacts. The person who chose this level quality is probably blind.<p>Also it often gives crazy advices, for example something like &quot;embed CSS code necessary to display the top of the page, right into the page&quot;. Not only it is difficult to implement, (what exactly is &quot;the top of the page&quot;? how to understand what part of the code is necessary? what if the user scrolls the page down while loading?), it will make the pages larger and doesn&#x27;t allow browser to cache embedded CSS. So you have to invest a lot of time and your page will probably load slower as a result.<p>But at the same time this script doesn&#x27;t notice obvious things. For example, it never advices to remove or replace web fonts although web fonts are heavy, can cause problems with rendering text (they can lack glyphs, for example cyrillic or CJK characters) and <i></i>web fonts block text rendering<i></i>. And they are really unnecessary in most cases because builtin system fonts usually look better at small sizes (at least on Windows).<p>Also it never advices to remove ads althogh ads often cause high CPU and memory consumption. Why is that I wonder.<p>The tool always requires to move JS scripts to the bottom of the page. But is it always the best idea? I think in most cases it is not. For example, if you have a button with an onclick handler, it will give a JS error if the button is clicked before the scripts in the bottom of the page have loaded (the problem of dead JS controls).  And if you put a small JS script at the top of the page, there will be no error. And what if you have a SPA? In this case the earlier you start to load the scripts the sooner the user will be able to see the data.<p>Also it always recommends to use a CDN which is not always good idea. For example, if you have a site in Russia or China and move your static files to CDN then it might be farther from the user than your server and even worse, it can get blocked so your site won&#x27;t even be loading. Adding a CDN often doesn&#x27;t make performance any better but reduces the reliability and increases your hosting bill.<p>So Google&#x27;s script might help you in identifying problems with your site but you should not ever blindly trust any of the recommendations. Please leave client side optimization to people who have expertise in this area.<p>By the way I had to lessen the image quality to get a better score  (and foolow other useless or even harmful recommendations) because our management believes that the score given by this tool (it is Google&#x27;s official tool after all) affects SEO rankings and obviously they are more important than image quality.