WordPress tips for speed and performance [closed]

I work with several large WordPress sites, news sites specifically, that have thousands of posts and thousands of visitors (300k/day). With the stuff below, and a well coded theme, with well written queries, we’re loading in 2.5s with 7 ad blocks from AdSense and RevContent.

  1. Do you have a CDN? I highly recommend a CDN if you don’t have one. Depending on your budget, you could go free with CloudFlare (if you’re just running AdSense and no DFP, you can turn on RocketLoader, which will increase speed), or you could use a premium service like MaxCDN (what I use) or Amazon Cloudfront (I have used).
  2. I really prefer not to use minifying plugins and prefer to minify and concatenate all CSS and JS manually. The reason being is that I get rid of another plugin, which can speed up the site, and I don’t put any strain at all on site having to minify the files. I use CSSMinifier.com and JavaScript-Minifier.com and I generally create a top.js and bottom.js file.
  3. To load JS files via async, you can use the following function, which is fantastic. All you have to do is add the JS files, like I listed below, with the file name and it’ll add async. Note that this only works for files load via wp_enqueue_script.

    function js_optimization($tag) {
      $asyncscripts = array('jquery.js', 'jquery-migrate.min.js');
      if(!empty($asyncscripts)) {
        foreach($asyncscripts as $asyncscript)) {
          if(true == @strpos($tag, $asyncscript)) {
            return str_replace(' src', ' async="async" src', $tag);
          }
          return $tag;
        }
     }
    add_filter('script_loader_tag', 'js_optimizer');
    
  4. Run your site through GTMetrix.com. It gives you PageSpeed and YSlow scores, with suggestions on how to speed up the site.

  5. The plugin BJ Lazy Load is great for speeding up the loading of the front end.

Leave a Comment