⚠ I havent edited this article.
These are the results: .
Why would you want a fast website? You care about your users, right? Then we don’t have to list anything better than that.
How to Build a Fast Website
Form submission? Let html handle that and then you can do the checks from the server. Besides, client side checks are very limited in effectiveness.
Step two: prefer JPEG images and compress them ruthlessly
Static website generators like GatsbyJS and Hugo allow you to optimize the images by compressing them at build time. Also, there are special Node.js scripts and apps that cann help you compress the images.
65% - 75% quality JPEGs are just right for the web. Whenever you compress the images to 75% quality, you can save more than 90% in size. You can compress a 5MB image at 100% to 400KB! That is huge.
Also, the reason you must always avoid PNGs is the fact that you can’t compress them like JPEGs. And when you do compress them, you lose tremendous visual quality.
In my case, I used Hugo to compress the images at build time using the following snippet:
As you can see, I am resizing the photos to 600 pixels maximum width. I don’t need anything larger since the images are displayed on cards smaller than that size.
For the other single post display, I adjusted it to 720 because of the maximum width of the page is around the same value.
The guidline should be your container width. If you have a container whose maximum width is 800px, there is no reason to make your images larger than 800px wide.
Step three: use a static website generator
A static website is faster than dynamic website because it is always sitting on the server ready to be sent to the client. This is as opposed to dynamic sites which are mostly generated for each request. If you cannot get away from dynamic websites, always use caching.
Step four: use external fonts correctly
This should have been step one. 😄
When you use external fonts, make sure they are not blocking. In this case, you load them such that it displays default fonts at first, then swaps out for the font of your choice when it has been loaded. This way, you will not block renders at all.
display=swap at the end of the url.
As a side note, only load the font weights that you actually need. Don’t load everything there is yet you only use two.
Step five: use a CDN
Cloudflare is free to use. And it allows your users to access your site at blazing speeds since they are accessing from the nearest data center. Content delivery network even works best if you are using a static website generator because then the assets of your website do not rely on a database or a dynamic server.
This article is still not covering everything, it is a work in progress. So, as shallow as it is, don’t shy from asking me questions for clarification. Cheers! you can shoot me an email through ck at elevatika dot com.
comments powered by Disqus
You might also like
10 Ways to Ensure You Write Future Proof Code as a Developer
Show Correct http or https Url in Django Rest Framework (DRF) Browsable Api for Hyperlinked Serializers
Building a Better Web By Improving Performance and Speed to Enhance User Experience
How to Start Programming - Learning for a Self-Taught Software Engineer, Developer or Programmer
The Tools I Have Used for Web, Desktop and Mobile App Development so Far
Authentication in Phoenix Framework Using Guardian - Boilerplate Code
Deploying/Hosting Django on a Virtual Private Server (VPS) Like Digital Ocean or Upcloud Using Caddy, Docker and Docker Compose
Phoenix Framework - Developing in WSL to Avoid Compilation Issues
How to Backup Your PostgreSQL Database to Google Drive Automatically Using Bash