
3 Ways to Improve Your WordPress Blog Speed
- April 29, 2016
- Leave a comment
Page load time can be tedious and drive users away. Increase in speed will be helpful for visitors on a regular basis and improve the customer experience. Here are the 3 tips to reduce the loading speed of your WordPress blog:
Leverage Browser Caching
Page load time can be reduced by setting up the future expiration time of resources like images, scripts and styles used on the blog page. These can be found in the .htaccess file. You can set the expiration through the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
## Leverage browser expires caching ## <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg "access 1 year" ExpiresByType image/jpeg "access 1 year" ExpiresByType image/gif "access 1 year" ExpiresByType image/png "access 1 year" ExpiresByType text/css "access 1 month" ExpiresByType text/html "access 1 month" ExpiresByType application/pdf "access 1 month" ExpiresByType text/x-javascript "access 1 month" ExpiresByType application/x-shockwave-flash "access 1 month" ExpiresByType image/x-icon "access 1 year" ExpiresDefault "access 1 month" </IfModule> ## Leverage browser expires caching ## |
Defer Parsing of JavaScript
The page loading <script> will take additional loading time. By deferring the parsing of your script, you can further reduce page load time. By using this tag it will render the page faster by minimizing the initial load time. You can accomplish this by placing the following code in your Theme’s functions.php file:
1 2 3 4 5 6 7 8 9 10 11 |
/** * Defer scripts */ if(!function_exists('presstigers_defer_parsing_of_js')){ function presstigers_defer_parsing_of_js ( $url ) { if ( FALSE === strpos( $url, '.js' ) ) return $url; if ( strpos( $url, 'jquery.js' ) ) return $url; return "$url' defer='defer"; } add_filter( 'clean_url', 'presstigers_defer_parsing_of_js', 11, 1 ); } |
Image Optimization
Page load time will be faster if you optimize all the images used. For this, specify the dimensions (width and height) to standardize all your images.
This returns defer’ I wonder why there is ‘ after that word?
Hello Amitpal,
Please replace the line # 8 of the second snippet with the following line of code:
return "$url' defer='defer";
Also, we will update this code in our article as well.
Thanks & Regards,
—
Abdullah | WP Plugin Developer
Email: support@presstigers.com