How to increase the speed of your WordPress site

One of the many questions I am asked is how to speed up your WordPress site? Or how to increase the speed of the WordPress site in gtmetrix, or how to increase the speed of the WordPress site in a principled way and also maintain it? While WordPress is an amazing content management system, if the principles of optimizing and speeding up WordPress are not followed, the website you build with this content management system will load a little slower and this slowdown will reduce your site’s ranking in Google. In other words, it will reduce the SEO of your site.


WordPress site speed training 2021

In this article, we will teach you how to optimize your WordPress website and discover the mysterious ways to speed up your WordPress speed. Most commercial websites in the world trust the WordPress content management system and use it to design their website. In 2017, more than 74 million websites will use the WordPress content management system.

Follow the article to have your fast paced WordPress website. Rest assured that by doing so, you will have a very positive impact on your website user experience and also note that increasing the speed of WordPress has a direct impact on the internal SEO of your site, so be serious in speeding up WordPress. Also, keep in mind that this tutorial has a direct impact on improving the speed of your WordPress site at


Use the optimal template

There is a theme or framework behind every WordPress website that may not be optimized. In coding, everyone uses their own method, and if you are not a developer, it is recommended that you use a solid, optimized shell. At the moment, simple skins like WordPress 2017 skins are one of the best suggestions for you because in addition to being simple, they are also very light.

Also note that you can also buy authentic skins from reputable stores. Just keep in mind that while there are many layouts available to you across the web, some developers are abusing the trust of stores and making a lot of money selling such layouts by adding a few features to a simple layout. However, our suggestion for buying a WordPress template is not Persian language stores, and also the speed of the site can not be evaluated based on the demo of the skin.

Use cache

Activating the cache on the site is another very important factor in increasing the speed of the WordPress website. Crawlers are static files made of your pages and articles that are stored in users’ browsers, reducing the load time of the website the next time users log in. You can do this with WordPress cache plugins, browser cache and server cache.

We suggest that you read the comprehensive article on troubleshooting leverage browser caching to better know about cache and how to activate it, but in any case, we provide a solution for the WordPress site with the help of plugins or code in the continuation of this article.

WordPress Cache Plugins

Here are some examples of free and commercial WordPress plugins in the field of cache:

  • Cache Enabler plugin
  • W3 Total Cache plugin
  • WP Super Cache plugin
  • WP Rocket plugin

Browser Cache – Add Expire Headers to WordPress

Most websites are unhappy that Leverage Browser Caching is disabled on their web server. By adding the following code snippet to the .htaccess file, you can enable browser cache for your website. This section is also available in some of the plugins listed above.

Also, if you want to get more information in this field, you can refer to the article on solving the problem of leverage browser caching by Mr. Pouria Ariafar. Of course, if your site speed is not good in GTMetrix, I suggest you make a video of 8 hours of site speed training.


<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault “access plus 1 month”
# My favicon
ExpiresByType image/x-icon “access plus 1 year”
# Images
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType image/jpg “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType text/css “access plus 1 month”
# Javascript
ExpiresByType application/javascript “access plus 1 year”

Server cache

In addition to WordPress plugins and browser cache plugins, servers can also use cache settings. Varnish cache, for example, is one of the most powerful choices in combining a CDN.

Use Prefetch on popular domains used by users

In this method you create a setting in the DNS of the website to load a part of your website, such as the famous js files that the user sees in most websites, so that this part of the website loads much faster when you enter the website.

To use Prefetch in WordPress, you must add a Syntax instance between the <head> and <head /> tags in the Header.php tab. For example, consider the following examples:

Using the Prefetch technique in Google Fonts:

<link rel = “dns-prefetch” href = “//”>

Using the Prefetch technique in Google Script Files (JQuery):

<link rel = “dns-prefetch” href = “//”>

Remove Query Strings from Static Resources:

Deleting query strings from static sources on your website is useful for the website in every way, because by deleting these strings you avoid the possibility of problems on the website.

1 – Open the functions.php file and put the following code in it:

function _remove_script_version ($ src) {
$ parts = explode (‘? ver’, $ src);
return $ parts [0];
add_filter (‘script_loader_src’, ‘_remove_script_version’, 15, 1);
add_filter (‘style_loader_src’, ‘_remove_script_version’, 15, 1);

2 – If you use plugins like WP Rockets, you do not need to apply these settings and these plugins do this automatically (if you want to buy a wp rocket plugin and also a complete tutorial on how to use this plugin you can in this Get the link)

3 – You can also install plugins like Query Strings Remover and Remove Query Strings From Static Resources in your WordPress.

If you are using a CDN, your CDN may be able to delete queries. Read your CDN documentation to find out.

Also, for complete information on this subject, you can refer to a very complete and useful article on removing query strings from static sources on the SEO teaching website.


Use a content delivery network or CDN

If you do not know what CDN is, be sure to read the CDN article. However, it does not matter how heavy your WordPress website is or how much traffic it is currently consuming, because the CDN service solves all these problems. A CDN service shares all your JS, CSS and image files from its cloud servers around the world so users can feel great speed and reduce file download times. We have talked about the benefits of using a very comprehensive CDN in detail in this post, and we have even published the Cloudflare tutorial on our site so that you can use the CDN easily.

In addition, connecting a CDN‌ to the website and increasing the speed will increase the conversion rate of your website and also reduce your bounce rate. (You may ask what is Bounce Rate? In the article What is a bounce rate, we did some interesting articles, be sure to read it) I have also prepared an article on dating and how to activate it in WordPress, which I also suggest you read.


Load all files from CDN

Make sure even the smallest files on your website, such as Favorites, are on the CDN. If all your website information is loaded from a CDN connection, your website speed will be multiplied.

To call favicon in WordPress from CDN, also change the following code to your website in the header.php file and load it from CDN.


<link rel = “shortcut icon” href = “” type = “image / x-icon” />


WordPress Database Optimization

If you do not optimize your WordPress database, it will start to slow down over time. There are several ways to optimally maintain a database that will help you limit and even disable post versions.

Disable or limit the number of WordPress copies

Follow me to solve this problem.

Disable transcripts

To disable duplicates you need to put the following code snippet in the wp-config.php file. This shifts the auto-save from 60 seconds to 5 minutes and also completely disables the copies.

define(‘AUTOSAVE_INTERVAL’, 300); // seconds
define(‘WP_POST_REVISIONS’, false);

In addition, there is an incredibly simple and light plugin that you can use on your website. The name of this plugin is Disable Post Revision and it does exactly what I told you in this article.

Restrict copies

To restrict copies you need to put the following code example in wp-config.php. This will allow WordPress to save automatically every 5 minutes and the maximum number of copies will reach 3. You can also increase or decrease the number of copies by changing the number 3.

define(‘AUTOSAVE_INTERVAL’, 300); // seconds
define(‘WP_POST_REVISIONS’, 3);


Clear old copies from the database

After restricting or deactivating copies, now is the time to clear the old copies. To do this, I suggest you use the great plugin as well as the free Wp-Optimize.

With this plugin you can delete all copies of your website articles, delete all automatically drafted articles, delete all spam and unverified comments, and in the new versions of this plugin you can delete all database optimization operations. Do it automatically. Do not forget to back up before making changes to the database.


Get rid of the limit of 100 WordPress pages

In general, WordPress websites are very sensitive in terms of pages and do not consider a website with more than 100 pages acceptable at all. If your website is longer than 100 pages, you will feel high RAM consumption as well as slowdown in the backend of your website. Note that these problems will not be felt in the front end of your WordPress website and have no effect on this part. Even the automatic company itself has mentioned information in this regard in its documentation section.

Due to the fact that WordPress is designed for content based websites, but some also use this content management system in various topics such as corporate websites due to the convenience of these websites. These websites require several different pages and by adding pages and creating problems in Back End has trouble managing their website. For such websites, it is recommended to create different Post Types by creating several different pages with one shape. You can also use the Post Type Switcher plugin to convert your pages to a Custom Post Type type and turn your pages into articles and fix the problem of slowness in the Back End.

Of course, in the WordPress database optimization article, we have dealt with the issues of improving the WordPress database in a very comprehensive and interesting way, and I definitely suggest you read this article at least once.


WordPress image optimization

Optimizing images and reducing their size is a very complex issue that requires careful consideration. And we at SEO teaching have published many comprehensive and useful articles about this, so try to read the SEO SEO articles carefully, because the WordPress images section is one of the most important and effective sections of your website.

The smaller the size of the images used on a page, the faster that page will load.


Enable Gzip compression on your website

Another important part of WordPress website optimization is Gzip compression, the activation of which reduces the size of the web page, CSS files and JavaScript. By activating Gzip you will save 50 to 80% of your website bandwidth. Of course, we have already talked about the Gzip function in detail in the Enable gzip compression post.


To enable GZIP in Apache, put the following code snippet in the .htaccess file.

<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application / javascript
AddOutputFilterByType DEFLATE application / rss + xml
AddOutputFilterByType DEFLATE application /
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

# Remove browser bugs (only needed for really old browsers)
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


To enable GZIP on the NGINX web server, paste the following code snippet into nginx.conf.

gzip on;
gzip_comp_level 2;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 1100;
gzip_buffers 16 8k;
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_vary on;


Reduce the number of plugins in WordPress

One of the most common reasons for slowing down websites is having too many plugins running on WordPress. As much as possible, try to use the minimum number of active plugins. Before you start disabling and clearing add-ons, it’s a good idea to analyze them and see which add-ons slow down your website.

After reviewing, now is the time to see if you can fix their problem. If you can not solve the problem then disable or delete them.

Plugin P3

P3 Plugin is a free plugin developed by GoDaddy that helps you solve your website slowdown problem. With this plugin you can:

  • Get the run time of each plugin
  • Get all the active plugins and load time of each.
  • What plugins slow down your website?
  • Number of queries in MySQL
  • Create tables of scan results

Note: This plugin is not currently compatible with PHP version 7.

Also keep in mind, with these plugins you can notice some problems but sometimes you have no choice but to uninstall the plugin.


Optimize the performance of web fonts

In a recent study on the performance of web fonts, about 57% of websites use personalized fonts, which has increased by about 850% since 2011.

SEO experts believe that webmasters should load only the formats they need on the website. For example, WOFF and WOFF2 are among these formats. Services such as Typekit increase download time and also slow down your website due to base64 encoding, but not in Iran. (Due to sanctions 😐)

In our experiment, Google Fonts used only the Woff format when using a CDN, giving you incredible speed. The Open Sans font is the fastest of Google’s top 10 fonts. If you want to have great speed in fonts, it is recommended to use a combination of Open Sans and Arial on your website.

The difference in load speed between fonts, for example secure web fonts as well as Google fonts, is about 200 milliseconds. Also, consider adding additional requests to your HTTP requests to load fonts on Google.

Another thing you can do is transfer the font file to the CDN. Most CDN provider websites offer a section for their users that allows users to add links to the most popular CSS and Js structures to their website via CDN. For example, below we will discuss the speed difference in the type of linking.

Note that you can add these sections to the browser cache so that once a user has downloaded it, there will be no need to re-download the file for a while and speed up your website.

We suggest using the LocalFont Tool to convert WOFF fonts to the Base64 encoding structure. This will give you a CSS file and a JavaScript file that you can use to speed up loading.


Awesome icon font optimization

There are several ways to optimize your WordPress website when it comes to Awesome icon fonts. If your WordPress theme uses Awesome fonts, please try one of the following ways to optimize your website.

The first way – load the Awesome font on the public CDN

To activate this section, you need to put the link provided in the open source CDN servers to the header.php file and in the <head> tag. The same goes for public CDNs. For more information, see General CDNs. Sample:

After placing this link in the Head section of your website, you can now use any of your favorite icons in the Awesome font on your website.

The second way – load the Awesome font on your CDN

Your second way, and indeed our suggested way, is for you to publish Awesome font information by uploading it from your CDN. The first reason is that a connection reduces DNS Lookup and this improves the loading time of the website.

After importing Awesome font files into your CDN, you need to put the CDN link in the <link> tag. For example:

<link href=”” rel=”stylesheet”>


Lazy loading of images, videos and comments

Lazy loading is currently one of the most controversial parts of website optimization. Regarding the lazy load in the pictures and videos as well as the comments section, we have already placed articles in SEO teaching that we suggest you refer to them to conclude the lazy load.

How to enable lazy loading of images and videos to speed up the website
How to optimize and also activate lazy load in WordPress comments section
After activating the lazy load on your WordPress, the load time of the website basically improves by 1 to 10 seconds. Especially on article-centric pages.


Compose and minimize HTML, CSS and JavaScript files

When it comes to optimization, file shrinkage and composition play a big role. Note, however, that downsizing is different from composition, and we’ll talk more about that later.


Minify or Minify in optimization means clearing the extra sections in HTML, CSS and JavaScript files. For example, the following are additional sections in these files:

  • Comments
  • Empty spaces
  • lines
  • Separating blocks

By deleting these sections you can increase the loading speed of your website.

If you use the WP Rocket plugin, you can enable Minify in it. Better WordPress Minify is also a great plugin in this area.

Of course, we have mentioned these issues in the gtmetrix tutorial.


Combining files means combining multiple CSS and JavaScript files into one file, which reduces HTTP requests. Most of the time this increases the download time of the files but prevents additional HTTP requests.

If you are using the WP Rocket plugin, you can merge files via the Merge option.

Also, if you are looking for free plugins, you can use the Merge + Minify + Refresh plugin, which in addition to being free, also has the ability to shrink files.


Reduce HTTP cross requests

Reducing the number of HTTP requests in WordPress is very important. Here’s how to put one together for use with your WordPress application.


If you use the default WordPress comment submission system, by default users’ user images are loaded through Gravatars, and to load each image an HTTP request is added to the number of page requests, and if you have a high number of comments on your website this The section will drastically reduce the speed as well as increase the number of HTTP requests on your website.

There are several ways to solve this big problem.

Solution One – Disable Gravatar

The first way is to disable Gravatar user image information retrieval and use a local importer. This is not ideal, but is it more important that the images of the users are ideal or the user experience that they get from the super speed of your website?

To do this, you can use a free plugin called WP User Avatar, which allows your users to easily upload their images to the core of your website. Also in the settings section you can click on the option Disable Gravatars and use only local avatars to completely disable Gravatar.

The second solution – lazy load

Lazy loading does not reduce the number of HTTP requests, but it does speed up your website because it loads Gravatar at a specific time. For more information on how to activate lazy load in the WordPress comments section, refer to the related article.

Deactivation of waves

After the release of version 4.2 of WordPress, emojis can also be used in WordPress. Unfortunately this means adding an extra js file called wp-emoji-release.min.js? Ver = 4.3.1 which will add an extra request to WordPress.

To disable as well as reduce another HTTP request, do the following:

The first way – install the plugin

You can completely disable the added emoji functions in WordPress by installing the Disable Emojis plugin developed by Ryan Hellyer for free.


The second way – WordPress Function Code

Get rid of add-ons that emojis create on your website without plugins. You can add the following code in the function.php section of your skin.

* Disable the emoji’s
function disable_emojis() {
remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 );
remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ );
remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ );
remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ );
remove_filter( ‘the_content_feed’, ‘wp_staticize_emoji’ );
remove_filter( ‘comment_text_rss’, ‘wp_staticize_emoji’ );
remove_filter( ‘wp_mail’, ‘wp_staticize_emoji_for_email’ );
add_filter( ‘tiny_mce_plugins’, ‘disable_emojis_tinymce’ );
add_action( ‘init’, ‘disable_emojis’ );

* Filter function used to remove the tinymce emoji plugin.
* @param array $plugins
* @return array Difference betwen the two arrays
function disable_emojis_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( ‘wpemoji’ ) );
} else {
return array();


Disable some scripts and CSS files in additional sections

Normally when you create multiple plugins on your website the JavaScript as well as CSS files are loaded in all parts of your website which slows down your website. A commercial plugin called Gonzalez solves this problem altogether, and you can only load the plugins you need on the website and disable other extras. By doing this you can speed up your website for large websites with multiple plugins for up to several seconds.

Disable Embeds

From WordPress 4.4, a new type of script called wp-embed.min.js was added to WordPress scripts, from which images, videos, tweets and other shareable structures could be easily placed on the website. For example, when you put a link to a YouTube video in WordPress visual editing, WordPress automatically converts it to a web-executable format. This script is useful in theory, but if you do not have the Gonzalez plugin, it will load on all of your pages, drastically slowing down your website.

Try one of the following ways to disable Embeds:

The first solution – WordPress plugin

A great free plugin on this subject is called Disable Embeds, developed by Pascal Birchler. This plugin disables all scripts loaded on the page and speeds up your website.

The second solution – WordPress Function

If you do not want to use the plugin and use the code optimally, put the following code snippet in your template functions.php file:


Disable comments

The comments section is also a very, very marginal and dangerous section that, if not properly protected, may even cause your website to crash. The best suggestion for having a good feedback system is to use third-party systems like Disqus, which also have their own problems, which is much less than the default WordPress comment system. To deactivate the WordPress comments section, you can put the following code in the functions.php section of your template.

// Remove comment-reply.min.js from footer
function comments_clean_header_hook(){
wp_deregister_script( ‘comment-reply’ );


Disable Hot Link

What are Hot Links? Suppose I upload a photo on my site and then use it on my site and now you like this photo and you want to use it on your site but you do not upload that photo like me but only the URL of the photo uploaded by You use me on your site and every time your site is opened by a user, my hosting server must respond to the request of that photo to your user so that it can be displayed. This will save my server bandwidth apart from the server conflict, unless your server has unlimited bandwidth. Now, if you want to disable this feature, you can enter the Cpanel of your site and apply the necessary settings from the Hotlink Protection section, or you can disable hot links or the same Hot Link via .htaccess.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)? [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L]

After disabling hot links, images are displayed with error 403.


Disable Pingbacks and Trackbacks

Pingbacks and Trackbacks are now the future of logins that slow down your website. This problem can be tracked by Ahrefs, Google Alerts and other monitoring brands.

To disable these two, go to the dialog section of your WordPress website and disable the option to allow other sites to send feedback on new posts.

Disabling this option means not allowing other people’s websites.


Specify the dimensions of the image

Most of you have a problem with website analytics regarding the size of your images. This error is related to specifying the dimensions of the image, for example, your original image is 500 pixels high, but you do not specify on the website how many pixels this image has, and the browser then has to take the time to find the dimensions of the images. However, if you want a much more comprehensive explanation, read the short and useful article on specifying image dimensions.


Slow loading admin-ajax.php in WordPress

In WordPress 3.6 or later, it automatically used the Heartbeat API to connect and integrate web browsers and servers. Which helped WordPress administrators in automatic management and storage.

In this API there is an ajax file called admin-ajax.php which is associated with the browser. This file is a large file that transmits heavy requests to the server. Consider that once you log out of your WordPress counter and log in again and repeat this process, it can go on until your WordPress server shuts down. Because every time the page is refreshed, this file will send a post request to your WordPress.

The free Heartbeat control plugin is designed to make it easy for you to manage so that you can control the amount of post requests sent by the heartbeat api and prevent your server from slowing down.

As you can see below, this config file without the above plugin will add about 500 milliseconds of time to load your website, which will solve your problem by adding this plugin.


MySQL settings

MySQL optimization is very important in optimizing websites. Unfortunately, many people do not provide optimal configurations for their MySQL system. The MySQL and MariaDB configuration sections are normally located at /etc/my.cnf.

Below are the settings that you must include on your website:

  • tmp_table_size
  • query_cache_type
  • query_cache_size
  • query_cache_size
  • join_buffer_size
  • max_heap_table_size

One of the best tools for creating an optimal MySQL script is MySQL Tuner. This tool is for reading only and does not allow you to configure and only suggests what to do. Other good tools for configuration and optimization include the following two tools:

  • MySQL tuning primer script
  • phpMyAdmin


Choose a reputable web hosting host

You should always choose a completely secure and reputable hosting server for your website. You should also consider that this reputable web hosting also provides credible optimization features for your website. Before buying any hosts, ask about the features as well as the access they give you, and ask the websites that use their services to check the speed of TTFB and.. TTFB time is very important and if you do not know about this I recommend reading the article What is TTFB.


We hope you find the article How to Speed ​​Up a WordPress Site useful and that you can use it to build a very fast website. By choosing a good host, optimizing the database, implementing a CDN, compressing images, clearing code, as well as reducing the number of HTTP requests, you can have a fast website.

Always keep in mind that SEO teaching Knowledge Base is always ready to answer you in various fields of the web, and we tried to implement the WordPress site speed training in gtmetrix with the help of this article.

Keywords: WordPress Speed ​​Principles, WordPress Speed ​​Plugin, WordPress Speed ​​Plugin, ‌, WordPress Speed ​​Plugin, Ways to Speed ​​Up Site, Ways to Speed ​​Up WordPress, Mysterious Ways to Speed ​​Up WordPress Site, Ways to Speed ​​Up WordPress, speeding up WordPress, how to speed up the site, WordPress speed boost code, important tips to speed up WordPress

Leave a Comment