Optimizing WordPress site
I'd read lots of articles about optimizing WordPress website but none of them provides a complete solution. Most of the posts are trying to sell their premium plugins or services which is annoying! So, I've decided to write one.
I'll attach a custom wp-config, .htaccess files and all other files mentioned in this post.
Some web sites for checking page speed
Enabling WP Cache caching wp-config.php
For enabling WP cache, edit
wp-config.php file in your wordpress's websites root directory and add those line below
/* WordPress Cache */ define( 'WP_CACHE', true );
Comporessing scripts and styles
Need to add some following constant values in
wp-config.php file. Make sure the following line is in wp-config.php and it is ABOVE the
/* Compression */ define( 'COMPRESS_CSS', true ); define( 'COMPRESS_SCRIPTS', true ); define( 'CONCATENATE_SCRIPTS', true ); define( 'ENFORCE_GZIP', true );
Serving static assets with an efficient cache policy
Static assets mean the images, CSS and js files which will not change frequently. And the
Cache policy means, when a user or client visit again your website, the user needs to download those CSS, js, and images in every visit to render this website properly. So, we need to cache those files to user browser until clears up the cache. It can be done by using a simple
Turning on gzip compression
Gzip is a technology that compress the HTTP responses so it will reduces the size.
Add those following line in
Note: This is only works on Apache Server. If you are running in NGINX server, add following line to
If you are using plugins like
wp super cache or
w3 total cache those plugins have option for enabling Gzip to your site. For WP Super Cahce, go to the WordPress dashboard > WP Super Cache > Advanced > check the box for Compress pages so they’re served more quickly to visitors.
Leverage Browser Caching in WordPress
Serve images through CDN
Cloudinary is good service for images. It allows image resizing, editing and also CDN services. It is good to serving images which will not frequently be changed. Cloudinary free plan gives 25GB storage and bandwidth. Which is enough for a personal and small business website which does not image heavy. Disclimar: Cloudinary doesn't sponsored this post :p
Minify JS, CSS and combine to one file
autoptimize which will do this job pretry well.
- Install autoptimize
- Go to settings > autoptimize > show advanced settings
- Make sure you've marked this with options exact same as below
Files for this post
Here you can find all of the files in the post Gist Link