Web development has evolved over the last couple of years. We load more and heavier files in the browser, but those things cost the user experience. Let's improve the page loading.
In this post, I want to share a few guidelines that help me keep the performance and user experience at a high quality.
I know this one sounds obvious, but minimizing the number of requests needs some more thought. If you don’t need an image, video, icon, pdf on your page, don’t load it even though users won’t see it.
So if you have a popup window with a YouTube in an iframe, load it when the user has opened the popup window. Not earlier.
When a user is not scrolling through a page, don’t load that image in your footer! The user doesn’t see it, so don’t waste any resources on it.
Only load external sources when you need them! It’s that simple.
I know we love those beautiful fonts from Google Fonts, TypeKit, or other services. But, do we need them? And do you need all of the family, or are we only using one style of that font?
Maybe we need to research finding a great safe web font that looks similar to our custom font. If it comes close, I would suggest picking that one!
Loading a custom font costs some time for the user to download, especially when they have a slow connection. It causes a bad user experience because it can block the complete page from being responsive.
A web-safe font is always safer, faster and improves the user experience in all kinds of ways. For the designers out there, even a web-safe font can improve readability and compliment the website’s branding.
Are you not convinced yet?
Next to that, “The performance cost of custom web fonts, and how to solve it” by Joshua Stopper is another great in-depth guide on how to keep your Webfont performed.
Icons, in websites and web apps, we can’t live without them.
Services like FontAwesome, Google Material Icons, and Iconmoon have made icon fonts popular! Icon fonts are great for customizing the colors for your brand. But like standard web fonts, they come with a cost.
A better alternative would be using inline SVG. I mean, just the code from an SVG file, not link it inside an image tag. By using inline SVG, you can style it with CSS as much as you like. Check the example below.
The cool thing is, you can also use some CSS animations with it. You can’t do that with an icon font, right. 😊
Earlier I said that you shouldn’t load things that are not used or hidden. Well, this is a critical thing for images. And nowadays it’s easier to fix than before.
loading="lazy" to your image tag like below.
<img src="image.jpg" loading="lazy" alt="Landscape The Netherlands" width="480" height="640px" />
Since we load so many external files into our browser, we have to keep them as small as possible.
Check the getting started pages for both tools to see how easy it is.
I’m a big fan of ViteJS because it’s a modern approach, and it’s super fast.
This is more of a mindset than a guideline.
Only load external resources when you need them. And only load it on pages, views, or dialogs that are using it.
Don’t waste precious internet bundles and processor power of the user’s device.
Sometimes you lead a website where they have banners at the top. But they forgot to preformat the image. Images of a few MB can cause prolonged loading times, and it is not what you want for your users ;-).
Formatting your images is very important!
Use the correct height, width, and file extension. Be careful with png files. They can be high quality but take up a lot of MBs.
- JPG: Use this for photos
- PNG: Use this for high-quality photos for download purposes and transparent images. Be careful. This comes with costly data.
- GIF: Use this for images or icons with a meager amount of colors
- WebP: This is a newer image type. It can hold very high-quality photos without the downside of png files.
But to do this the easy way, create a free account at Cloudinary, and you can format all your images on the fly.
For example, the images from my blog are formatted with Cloudinary with this link:
Cloudinary offers great documentation on how you can format your images and videos with their service.
As you can see, there are a few guidelines to follow to create a fast-loading website. These are my personal favorites. I’m fully aware that are many more things than my seven guidelines, so if you have some tools that you use yourself, please leave them in the comments to share them with the world.
After reading this post, I hope you learned something new or are inspired to create something new! 🤗
If I left you with questions or something to say as a response, scroll down and type me a message. Please send me a DM on Twitter @DevByRayRay when you want to keep it private. My DM’s are always open 😁
Want to reach me for comments or questions on my blog? Send a DM on Twitter @DevByRayRay