Every WordPress site owner, atleast once, have to Optimize their WordPress site and keep it monitored in order to make it compatible with the SEO and to give a better user experience (UX).
WordPress Sites’ performance Plays a vital role in your site and as well for your ranking in Google. A slow site is neither preferred by google nor by visitors. The better the Optimization is, the better the result for a site is. Aa well-optimized site can easily rank on google search base, in thir contents and keywords as well.
When we build our sites in WordPress, most of the us only focus on the layout/designs. We forget to give any attention to optimizing it.
Unnecessary, unorganized and unoptimized plugins or themes cause lots of issues for a site along with security threats. So be careful about null plugins/themes on your WordPress sites.
Before doing the optimization first we have to know where and how the issues were generated and what needs to be fixed.
For this kind of test there are lots of tools, but there are only three kinds which we can trust and depend on the results:
PageSpeed Insights – Google Developers
Google’s PageSpeed results will generate all sorts of issues and in order to resolve most of these issues, one needs to be experienced in WordPress.
In this article, we will show how you can resolve your WordPress optimization issues in a simple way.
To start, go to Gtmetrix and scan your site. After the scan you will see results which may look somewhat like the followings:
In this screenshot, you can see three issues:
Serve scaled images
Optimize images
Minify JavaScript
First two issues are image related, which we can be resolve by a free plugin called:
In this plugin page, you can see how to setup the plugin and optimize your images according to the error.
After the setup, run the image optimization to get an expected result.
And now for Minify Javascript and Cache issues, install these two plugins:
These two plugins together gives a great performance for most of the sites.
As they optimize all CSS, JS, and HTML, some sites due to server settings might have issues with the layout. Make sure you get a backup or have FTP/cPanel access disabled for those plugins to avoid any mishaps.
Finally, run the test again to find out if all seems good after the install of the plugins and check the results on GTmetrix:
As you can see we have resolved the issues and achieved an expected result related to the Page Load time for your WordPress site.
Some other common problems we get facing Gzip Compressions and Expired Headers.
Add the following line of codes at the end of your .htaccess document
# BEGIN GZIP COMPRESSION
<IfModulemod_gzip.c>
mod_gzip_onYes
mod_gzip_dechunkYes
mod_gzip_item_includefile.(html?|txt|css|js|php|pl)$
mod_gzip_item_includehandler^cgi-script$
mod_gzip_item_includemime^text/.*
mod_gzip_item_includemime^application/x-javascript.*
mod_gzip_item_excludemime^image/.*
mod_gzip_item_excluderspheader^Content-Encoding:.*gzip.*
</IfModule>
Add the following line of codes if your website is hosted on an Nginx server.
gzipon;
gzip_comp_level2;
gzip_http_version1.0;
gzip_proxied any;
gzip_min_length1100;
gzip_buffers168k;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_disable"MSIE [1-6].(?!.*SV1)";
gzip_varyon;
Add Expire headers code to .htaccess
.
<IfModule mod_expires.c>
ExpiresActive on
# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault "access plus 1 month"
# Data
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
# Favicon (cannot be renamed)
ExpiresByType image/x-icon "access plus 1 week"
# Media: images, video, audio
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
# Webfonts
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
# CSS and JavaScript
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
</IfModule>