
How to make your website load in less than 5 seconds
Its no news that a slow loading website is very bad for business.
In fact, 47% of Nigerian users expect websites to load in 10 seconds or less
— and 40% will abandon a page that takes 20 or more seconds.This means that if your site takes more than 20 seconds to load, you lose almost half of your visitors before they even arrive on your site.That alone is a huge blow to your potential conversions.
And for the visitors that decide to stick around, your slow load time can deter them from returning in the future.
After designing that beautiful platform, it will be a shame if users cannot view it because it is too slow at loading.
How can we speed up the load time for our wesite?
1. Check and reduce the size of large images on your site
2. Mininify your js & css files (remove duplicated functions, styles and whitespaces)
You can minify your JavaScript and CSS code using an online tool. You can click here to minify your .is and .CSS files
3. Avoid to many http requests ( merge some of your js & css scripts as one)
and make sure all heavy js scripts are placed just before the </body> tag
4. Enable browser caching ( This can be done by adding a few lines of code to your .htaccess file)
This will make files such as images, js, icons, css, js to only load from your server once, subsequent visits to your site will load those files directly from the cached memory of the visitors device, therefore making load time almost instant.
To enable browser caching for specific duration just add the following lines of code in your htaccess file
480 weeks
<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"
</FilesMatch>
# 2 DAYS
<FilesMatch ".(xml|txt)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</FilesMatch>
# 2 HOURS
<FilesMatch ".(html|htm)$">
Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>
5. Enable gzip
gzip is a compression system that is available on almost all browsers. Enabling it can reduce your page’s total size by over 70%, therefore improving load time.
You can enable gzip by adding the code to your .htaccess file.
.htaccess
file:<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
Otherwise just add the following line of code instead.
php_value output_handler ob_gzhandler
Note: both the caching & gzip codes for htaccess can be found online as open source to be copied and paste in your htaccess file.
Now your platform will load faster and your conversion rate will increase.
Leave a Reply