Backup the existing database
Backing up the database can be done manually (by logging into PHPMyAdmin) in the website’s host, or you can do it by using the WordPress plugin Updraft Plus.
This plugin also allows for schedule automatic backups. After making the backup download the database to your local PC to have it in case something goes wrong.
Update WordPress
See if the WordPress installation is up to date by going to the “Updates” section in the administration panel. If there is a more current version, update the WordPress.
Image optimization
Optimizing images can be done manually and with a wordpress plugin.
Manual image optimization without losing quality (lossless optimization)
For manual image optimization, you need to first download all images from the wordpress installation to your computer. Images are usually located in the “wp-content/uploads” folder.
For Windows, you can use the program FileOptimizer. Download and install the program. Open the program and press “File” and then “Add file”. Select the images you’ve downloaded from the WordPress website and then click “Optimize” followed by “Optimize all” to start the optimization. It will take some time to go after each image.
For Mac, use the software ImageOptim. It is very similar to FileOptimizer but is designed to work with iOS.
Using a WordPress plugin
The plugin is called Imagify. After you install it on the site, you need to register an account at Imagify.io to get an API key. After registering, you need to copy the API in the plugin and you should be able to use if afterwards.
In the plugin you have 3 types of optimization. Normal compression is a “lossless” optimization. This means there is no loss of image quality. Aggressive and Ultra compression are more powerful, so the picture quality will be somewhat reduced. The weight of the image will be much less.
Note: Free accounts have 25MB per month and images over 2mb will not be optimized. If images are over 2mb than most probably they are huge and need to be made smaller and then optimized.
Load jQuery from Google’s CDN in WordPress
WordPress loads jQuery from your server by default. It’s much better to load jQuery from Google’s CDN (content delivery network). Here are the 4 main reasons: Your visitors probably already have jQuery from Google’s CDN cached. This means jQuery will load nearly instantly. It’s probably faster to load jQuery from Google’s servers than your servers. They have faster servers and better networks. They also probably have a data center that’s closer to your visitor. Browsers will download jQuery in parallel with your local scripts. Browsers usually limit concurrent downloads to 4-8 from the same domain. You get to save on bandwidth. You should load jQuery from a CDN 99.9% of the time. If you don’t want to use Google’s CDN, you can use a CDN from cdnjs or jQuery. Here’s the code to load jQuery from Google’s CDN:
add_action('init', function() { if (is_admin()) { return; } global $wp_scripts; if (isset($wp_scripts->registered['jquery']->ver)) { $ver = $wp_scripts->registered['jquery']->ver; } else { $ver = '1.12.4'; } wp_deregister_script('jquery'); wp_register_script('jquery', "//ajax.googleapis.com/ajax/libs/jquery/$ver/jquery.min.js", false, $ver); });
Minifying resources (HTML, CSS and Javascript)
Minifying is basically removing all the unnecessary characters in the code, making it more lightweight, which translates into faster loading speed. It removes white space characters, new line characters, comments and other unnecessary parts of the code to save precious bites.
For wordpress you can use the plugin called AutoOptimize to minify HTML, CSS and JS. Install and activate the plugin and head to the main settings. There you can checkmark all 3 file types for minification and save changes. You should now experience quicker webpage loading.
Optimizing Time to First Byte (TTFB)
The first byte time is the time it takes to receive the first byte of information to your browser from the server. It depends on the speed a which the server can process the request and send the data. Each new plugin to the WordPress installation usually increases the first byte time, since more tasks are given for the server to complete before sending the website over to the user’s browser.
Therefore optimizing the FBT is a matter of shortening the work and response time of the server when a request is received. Instead of waiting for the server to make the SQL request and wait for the server to read the database, collect the information and organize it into an html file, we can cache the product (the html file) so that the next time someone loads this page it will be delivered much faster, without having to wait for the server to compile it from scratch.
To do that you can use the WordPress plugin called WP Super Cache. Install and activate the plugin. Than head over the the plugin admin page and click “Caching On”.
Than go to the “Advanced” tab to set some recommended settings.
- Select “Don’t cache pages for known users. (Recommended)”
When a users is logged in most of the times there is some personalized information, which is unique for the user so caching pages for them is recommended to be off.
- Select “Clear all cache files when a post or page is published or updated”
In the sidebar of some websites is a list of latest posts, so when a new page or post is published this list is updated. But if you are showing a cached version of this list, your new post or page will not be visible there. Having this option on ensures that this kind of lists are updated.
Save all changes and you’re done.
Cleaning the database
Each time a page is edited a new revision of the page is saved in the database. Now imagine a big website with lots of pages, when updated frequently over the course of a few year will have lots of revisions, which will never be used and are just poluting the database. This makes it harder for the server to find the right information in the database, since it needs to crawl a lot of database entries to find what is needed.
That’s what we will be doing now – delete unnecessary database entries. To do that we can use the WordPress plugin called WP Optimize. Install and activate the plugin. Go to the plugin admin page where you can see an estimation of how much space in the database you can free.
Please note: It is important to make sure that you’ve got the database backed up somewhere safe before running any optimizations on the database. Also you should be aware that you will be deleting unapproved comments.
You can now run the suggested optimizations and the database will be cleaned from unnecessary entries.
Security plugin for WordPress
So now that you’ve made all the optimizations and the website loads even quicker, it’s a good idea to put some security in place if there isn’t any. A good option for WordPress security is the plugin Wordfence Security. Install and activate the plugin, do the initial configuration (Wordfence will try to see what your server is and adjust itself to it). It’s a good idea to enable automatic updates on the plugin to make sure the security updates without you having to do it manually.
Caching files with caching headers
Next thing we want to do is tell the browsers to keep some of the files from the websites locally, so that the browsers automatically load the local resources, saving loading time and bandwidth.
Using caching headers set in the .htaccess file, you can do just that. Copy the following code in your website’s .htaccess file (usually found on the main folder of the WordPress installation).
# 1 YEAR <FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|woff|woff2)$"> Header set Cache-Control "max-age=31536000, public" </FilesMatch> # 1 WEEK <FilesMatch "\.(jpg|jpeg|png|gif|swf)$"> Header set Cache-Control "max-age=604800, public" </FilesMatch> # 1 WEEK <FilesMatch "\.(txt|xml|js|css)$"> Header set Cache-Control "max-age=604800, public" </FilesMatch>
Notice the “max-age” part of the code – it indicated the number of seconds you’d like to have the file cached on the user’s browser storage. Also, “<FilesMatch” indicates the file extensions of the files that we want to be cached. If you believe that more/less file extensions should be selected you can re-adjust the code accordingly.
Compression of transfer
Gzip is a way to compress website resources before sending them over the network from the server to your browser. It drastically reduces the time to transfer the files, decreasing loading time. It can reduce the size the file sizes of pages by up to 70%!
If the website is using an Apache server, then you can activate the gzip compression by copying the following code into the .htaccess file of the website.
<ifmodule mod_deflate.c> AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/vnd.ms-fontobject AddOutputFilterByType DEFLATE application/x-font AddOutputFilterByType DEFLATE application/x-font-opentype AddOutputFilterByType DEFLATE application/x-font-otf AddOutputFilterByType DEFLATE application/x-font-truetype AddOutputFilterByType DEFLATE application/x-font-ttf AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE font/opentype AddOutputFilterByType DEFLATE font/otf AddOutputFilterByType DEFLATE font/ttf AddOutputFilterByType DEFLATE image/svg+xml AddOutputFilterByType DEFLATE image/x-icon AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/xml BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html Header append Vary User-Agent </ifmodule>
Save the .htaccess file and do a Webpagetest to see if compression is working properly.
Quick website loading speed is even more important with the latest Google updates. Don’t miss the opportunity to rank better in Google by hiring us to make your website as quick as possible.