Search

Category Archives: WordPress

Beyond being a thorn in the side of many a WordPress webmaster, Google’s PageSpeed Insights tool is also one of the most well-known tools for WordPress speed optimization.

This free tool accepts your site’s URL and spits back two scores that indicate how optimized your site is for mobile and desktop visitors.

These scores are no longer just theoretical – they’re now based on real performance data, and they also have a real effect on your site, with Google using page speed as a ranking factor for both its desktop and mobile search results.

In this post, we’ll explain the recent changes to PageSpeed Insights. Then, we’ll share some WordPress page speed tips that you can use to speed up your site and get a better score.

Explaining How The New PageSpeed Insights Tool Works

In the past, PageSpeed Insights only provided a set of suggestions to optimize your site, with your score based upon how well your site implemented those suggestions. It did not include any real-world performance data in its page speed test.

That’s changed with the newest version. Now, PageSpeed Insights grades your site on how it actually performs using a tool called Lighthouse.

The latest version of PageSpeed Insights includes two types of real-world test data:

  • Lab data – this is an emulated test that shows how long it takes your site to load on a mobile network (e.g. 3G).
  • Field data – this incorporates real data from real anonymous mobile Chrome users via the Chrome User Experience Report (CrUX).

Because lab data uses fixed conditions, while field data includes a variety of devices and connection speeds, it’s normal to see different results between the two.

Based on how quickly your site loads for various performance metrics (full table), Google gives you a score that places your site into one of three buckets:

  • Fast – 90-100.
  • Average – 50-89.
  • Slow – 0-49.

According to Google, “100 is the best possible score which represents the 98th percentile, a top-performing site. A score of 50 represents the 75th percentile.”

WordPress speed optimization - screenshot of WPZOOM's score

This ranking matters for a couple of reasons.

First, Google uses page speed as a ranking factor on both mobile and desktop devices. If your site is in the red (0-49), that means it loads slowly compared to other sites, which might negatively affect your site in Google’s rankings.

Second, Google makes speed a factor because of the connection between page speed and user experience. Humans just plain don’t like slow-loading websites, especially when browsing from mobile devices.

Why Your Mobile And Desktop PageSpeed Scores Might Be Different

When you test your site, it’s not uncommon to see a high desktop score and a low mobile score. Here’s why:

Desktop users experience your site from a comparatively high-powered device and a comparatively fast Internet connection.

Mobile users are the opposite – they’ll typically have a device with a less powerful CPU and be browsing from a slower mobile connection (those are also the conditions Google uses to emulate its test).

For those reasons, it’s quite possible to have a site that’s faster-than-average for desktop visitors (90+ score), but slower-than-average for mobile visitors (sub-50 score).

Here are two examples why that might happen:

  • Image-heavy site. For desktop users, those extra images might not have much effect. But on a slower 3G connection, those images might take significantly longer to load.
  • JavaScript-heavy site. A laptop might have no problem quickly processing lots of JavaScript, but a low-powered smartphone might take significantly longer to parse and process the code (Google uses a mid-tier Moto 4G for its emulation tests – not the latest flagship smartphone).

Minimize Javascript for WordPress page speed

Both of those suggestions only apply to the mobile score and deal with the time it takes to parse and process JavaScript.


WordPress Speed Optimization: How To Improve Your PageSpeed Insights Score

Ok, now for the fun part – how to actually improve your WordPress site’s PageSpeed scores. Here are 6 tips that you can implement today to speed up your site and improve your score.

1. Enable GZIP Compression

GZIP compression shrinks the size of the files that your server sends to visitors’ browsers by a significant amount (up to 70%):

Some caching plugins – like WP Rocket – include GZIP compression functionality.

Alternatively, you can add the following code to your site’s .htaccess file:

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>

2. Optimize Images

To automatically resize and compress your site’s images, you can use a free plugin like Smush or ShortPixel. ShortPixel can also help you serve WebP images, which helps with PageSpeed Insights’ “serve images in next-gen formats” suggestion:

You can also enable lazy loading with the free Lazy Load by WP Rocket plugin, which waits to load below-the-fold images until a user starts scrolling down. This is a really nice method for WordPress speed optimization.

3. Eliminate Render-Blocking Javascript

“Render-blocking” JavaScript prevents your site from loading human-visible content until the blocking JavaScript finishes loading. This can be especially punishing on your mobile score, for reasons we discussed above:

For a non-technical solution, you can use the Async JavaScript plugin to async or defer JavaScript:

Make sure to thoroughly test your site afterward, as this all-in approach can break certain scripts.

4. Leverage Browser Caching

Browsing caching lets you store certain static assets – like your site’s logo – on visitors’ local computers to prevent visitors from needing to download those files on each page load.

Many caching plugins include browser caching. Otherwise, you can add this code snippet to your site’s .htaccess file:

<filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">

Header set Cache-Control "max-age=604800, public"

</filesMatch>

5. Minify JavaScript And CSS

Minification lets you shrink the size of JavaScript and CSS files by eliminating unnecessary white space:

Many caching plugins include minification functionality. Or, you can use a dedicated solution like the free Autoptimize plugin:

6. Reduce Server Response Time

Part of server response time is your host’s performance, so one solution here is to simply upgrade to a faster host.

Other options to reduce server response time include:

Wrapping Up: WordPress speed optimization

Putting these WordPress speed optimization tactics into action isn’t just about improving the two numbers on your screen.

By optimizing your site, you’re speeding up its page load times. That means a better experience for your visitors, and it also means giving your site the best chance possible to reach more visitors in Google’s search results.

Apply these WordPress page speed tips today and start enjoying a faster WordPress site.

The emergency is a plugin created by villageidiot but no longer available. Use this Script with great CARE!

Using the Emergency Password Reset Script

If the other solutions listed above won’t work, then try the Emergency Password Reset Script. It is not a Plugin. It is a PHP script.

Warnings
  1. Requires you know the administrator username.
  2. It updates the administrator password and sends an email to the administrator’s email address.
  3. If you don’t receive the email, the password is still changed.
  4. You do not need to be logged in to use it. If you could login, you wouldn’t need the script.
  5. Place this in the root of your WordPress installation. Do not upload this to your WordPress Plugins directory.
  6. Delete the script when you are done for security reasons.
Directions for use
  1. Save the script below as a file called emergency.php to the root of your WordPress installation (the same directory that contains wp-config.php).
  2. In your browser, open http://example.com/emergency.php
  3. As instructed, enter the administrator username (usually admin) and the new password, then click Update Options. A message is displayed noting the changed password. An email is sent to the blog administrator with the changed password information.
  4. Delete emergency.php from your server when you are done. Do not leave it on your server as someone else could use it to change your password.
<?php
/*
  This program is free software; you can redistribute it and/or modify
    	it under the terms of the GNU General Public License as published by
    	the Free Software Foundation; either version 2 of the License, or
    	(at your option) any later version.

  This program is distributed in the hope that it will be useful,
    	but WITHOUT ANY WARRANTY; without even the implied warranty of
    	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    	GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
    	along with this program; if not, write to the Free Software
    	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

require './wp-blog-header.php';

function meh() {
  global $wpdb;

  if ( isset( $_POST['update'] ) ) {
    $user_login = ( empty( $_POST['e-name'] ) ? '' : sanitize_user( $_POST['e-name'] ) );
    $user_pass  = ( empty( $_POST[ 'e-pass' ] ) ? '' : $_POST['e-pass'] );
    $answer = ( empty( $user_login ) ? '<div id="message" class="updated fade"><p><strong>The user name field is empty.</strong></p></div>' : '' );
    $answer .= ( empty( $user_pass ) ? '<div id="message" class="updated fade"><p><strong>The password field is empty.</strong></p></div>' : '' );
    if ( $user_login != $wpdb->get_var( "SELECT user_login FROM $wpdb->users WHERE ID = '1' LIMIT 1" ) ) {
      $answer .="<div id='message' class='updated fade'><p><strong>That is not the correct administrator username.</strong></p></div>";
    }
    if ( empty( $answer ) ) {
      $wpdb->query( "UPDATE $wpdb->users SET user_pass = MD5('$user_pass'), user_activation_key = '' WHERE user_login = '$user_login'" );
      $plaintext_pass = $user_pass;
      $message = __( 'Someone, hopefully you, has reset the Administrator password for your WordPress blog. Details follow:' ). "\r\n";
      $message  .= sprintf( __( 'Username: %s' ), $user_login ) . "\r\n";
      $message .= sprintf( __( 'Password: %s' ), $plaintext_pass ) . "\r\n";
      @wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Your WordPress administrator password has been changed!' ), get_option( 'blogname' ) ), $message );
      $answer="<div id='message' class='updated fade'><p><strong>Your password has been successfully changed</strong></p><p><strong>An e-mail with this information has been dispatched to the WordPress blog administrator</strong></p><p><strong>You should now delete this file off your server. DO NOT LEAVE IT UP FOR SOMEONE ELSE TO FIND!</strong></p></div>";
    }
  }

  return empty( $answer ) ? false : $answer;
}

$answer = meh();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>WordPress Emergency PassWord Reset</title>
  <meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php bloginfo( 'charset' ); ?>" />
  <link rel="stylesheet" href="<?php bloginfo( 'wpurl' ); ?>/wp-admin/wp-admin.css?version=<?php bloginfo( 'version' ); ?>" />
</head>
<body>
  <div class="wrap">
    <form method="post" action="">
      <h2>WordPress Emergency PassWord Reset</h2>
      <p><strong>Your use of this script is at your sole risk. All code is provided "as -is", without any warranty, whether express or implied, of its accuracy, completeness. Further, I shall not be liable for any damages you may sustain by using this script, whether direct, indirect, special, incidental or consequential.</strong></p>
      <p>This script is intended to be used as <strong>a last resort</strong> by WordPress administrators that are unable to access the database.
        Usage of this script requires that you know the Administrator's user name for the WordPress install. (For most installs, that is going to be "admin" without the quotes.)</p>
      <?php
      echo $answer;
      ?>
      <p class="submit"><input type="submit" name="update" value="Update Options" /></p>

      <fieldset class="options">
        <legend>WordPress Administrator</legend>
        <label><?php _e( 'Enter Username:' ) ?><br />
          <input type="text" name="e-name" id="e-name" class="input" value="<?php echo attribute_escape( stripslashes( $_POST['e-name'] ) ); ?>" size="20" tabindex="10" /></label>
        </fieldset>
        <fieldset class="options">
          <legend>Password</legend>
          <label><?php _e( 'Enter New Password:' ) ?><br />
          <input type="text" name="e-pass" id="e-pass" class="input" value="<?php echo attribute_escape( stripslashes( $_POST['e-pass'] ) ); ?>" size="25" tabindex="20" /></label>
        </fieldset>

        <p class="submit"><input type="submit" name="update" value="Update Options" /></p>
      </form>
    </div>
  </body>
</html>
<?php exit; ?>

 

Important ! Don’t forget to Delete emergency.php from your server when you are done.