If you’ve ever looked at improving your site’s SEO or Google Adwords campaigns, you’ve likely used Google’s PageSpeed Insights tool to see your site’s PageSpeed score. Unfortunately, Google doesn’t get very specific about optimizations for WordPress with this tool. To show how you can improve these metrics, WP Engine is here to help!
Google’s PageSpeed Insights provides a score of 0-100, based on how well your site performs on a set of specific metrics for both mobile and desktop users. It uses a page rendering tool to measure these metrics, so keep in mind that they are not rendering the site as a real visitor would.
With that in mind, Google PageSpeed Insights is intended to help provide general best practices for all kinds of websites, internet-wide. However, your score in this tool could affect the kind of ads your sites using Google Adwords receive, and potentially even your page ranking. Many developers try to reach a higher score with Google PageSpeed Insights as a result. We are here to help identify common areas where a PHP site running WordPress can be optimized to increase your score.
If your Google PageSpeed score says you need to optimize images, first check out which images could be optimized by clicking the blue “Show how to fix” option. This will show you which images on your site are larger than the frame that the browser loaded them in.
Most often these images will show as loading from your site’s domain or your CDN URL. If this shows images pulled from other sources online, consider downloading these images locally and uploading them through your WordPress Admin Dashboard to load them natively on your site.
Either of these plugins will help compress your site’s images so it serves them at the right scale for each device connecting to your site. WordPress already does the work of deciding which is the correct image size to serve to your users once it is compressed.
If you use a tool like http://www.webpagetest.org/, it will give you a better a visual of this:
Often times these files can be “deferred” or relocated to load in your site’s footer instead, which allows the site to start displaying content before those files are loaded later on.
Avoid landing page redirects
This recommendation should be pretty self-explanatory. Don’t redirect your site’s home page to somewhere else! For example, redirecting myhomepage.com to m.homepage.com for mobile requests would have negatively impacted the amount of time it takes a mobile user to load your site.
These days, most WordPress themes are responsive, meaning they automatically can load your mobile version of your theme for mobile browsers without having to redirect to a different site.
This warning could also be a red herring – for instance, if you tested www.myhomepage.com but your site uses myhomepage.com as its primary domain, it would register as a redirect even though most users would request myhomepage.com by default. Be sure you test the URL each user lands on when requesting your site when using Google PageSpeed Insights.
Prioritize visible content
Leverage browser caching
Troubleshooting this warning can be difficult–since those resources aren’t being loaded from WP Engine’s servers, they can’t add headers to those resources to direct the browser to cache them. To fix this issue, download the scripts or files to your website and load them from your own domain–when loading from your domain, WP Engine will automatically add the caching directives to these files.
On WP Engine, we already use gzip compression on the server to compress the following resources automatically:
Click the blue “Show how to fix” section to see which resources should use gzip compression. Most often these will be external resources, which are beyond WP Engine’s control to compress. However, if you download those resources and load them from WP Engine’s servers, our server directives will tell the server to gzip them by default.
If you do see resources served from your site itself in the list, check to see what kind of file the resource is, and see if it matches the list. If it isn’t one of the file types we automatically gzip, you can add these rules in your site’s .htaccess file instead.
Reduce server response time
Server response time can be affected by a number of factors. Google measures this metric by looking at the “Time to First Byte,” or TTFB. This can be influenced by things like network traffic and server load, but most often it has to do with the amount of time it takes to process the PHP code and database queries required to generate the page.
If you are intermittently seeing poor scores in Google PageSpeed Insights where it shows the server response time as an issue, this means your site’s cached pages are fine, but uncached pages are taking longer. To some extent, this is normal (since cached requests don’t need to process the PHP code and queries like uncached ones do). But for anything over 2 seconds, you may want to look into our article Troubleshooting Time to First Byte for more help.