
8 Tips on Website Load Speed Optimization. Part 1
Performance optimization is a hot button topic for any website owner.
1. Compress the files.
- For W3 Total Cache: check the “Enable HTTP (gzip) compression.” box
- Enable Gzip in .htaccess file
- Add this code <?php if (substr_count($_SERVER[‘HTTP_ACCEPT_ENCODING’], ‘gzip’)) ob_start(“ob_gzhandler”); else ob_start(); ?> at the top of HTML/PHP file
- Use plugins to enable Gzip
2. Minify JavaScript and CSS
- WillPeavy
- WP Rocket
- BWP minify (for WordPress only)
3. Fix render-blocking JavaScript
- Use specialized plugins.
There are two most popular plugins that can help you get rid of blocking JS (and CSS): Autoptimize and W3 Total Cache.
Autoptimize is simpler and W3 Total Cache demands a bit more work. The W3 Total Cache is mostly recommended for those users who already have experience with this plugin.
- Inline blocking JavaScript
As recommended by Google, you can inline the external blocking scripts content directly in the HTML document (upon the condition these scripts are small enough). This will eliminate the request latency and will fix the issue.
It is important to remember that inlining will increase the size of the HTML document, though, and the same script content may need to be inlined multiple times. To prevent the risk of hurting the performance, it’s recommended to stick with the small script inlining only.
- Use the async attribute
To make the JavaScript asynchronous and prevent it from blocking the parsing, use the async attribute on the external blocking scripts. Example: <script async src=”my.js”>
Remember though that asynchronous scripts would not execute in a specific order. As well, they should not use document.write.
4. Enable browser caching.
- WordPress: W3 Total Cache
- Static HTML sites: enable cache in .htaccess file
- Drupal: Varnish
Victor Petrov
View all articles by this author.