loading...

Fast website

3th of November 2019 - by Andrea Mazzilli.

andreamazzilli.com 2019 fast website

Increase your website performance.

In more than 2 decades of developing websites I came up with some rules that you should definitelly follow if you want to make your website faster. And when I say fast I mean the fastest possible. Keep reading and it will be clear how to improve your website performance.

Optimize your HTML.

HTML files are the first resources that browsers load when you visit a website. It is really important to understand which is the best practice to create an optimized HTML page, because it can really improve your website performance. Every HTML page has 2 main elements: head and body. The browser will first parse the HTML, then wait for all the resources (specified in the head) to be loaded and finally render the body. The more resources you include in the head the slower your page will render the body. The body is actually what users are going to see, so you need to be sure that the body will render as fast as possible. In order to have a fast website page you need to be sure your head tag doesn"t load heavy resources. How? Just load them at the end of your body. The page will then render the content first giving to the user a good experience. Usually heavy resources are JavaScript and Media files.

Optimize your JavaScript.

JavaScript is the only language to make your website interactive. JavaScript resources can be quite heavy, but if you follow the best practice rules, your code will be lighter. In order to make your JavaScript files lighter you have to minify and uglify them.

Serve compressed resources on Http2.

Make your website fast is not only about optimizing you HTML and JavaScript files, it's also important how your server is going to serve these resources. Your web server needs to use gzip compression and serve every resource through the new http2 protocol. Http2 replaces the Https protocol and it is able to handle multiple requests at the same time resulting into really speeding up your page loading time.

Use a cache system.

Browsers already use cache to save time and not reload the same resource everytime (if it is the same). You can also use cache in your web server to be sure that when you ask for a resource your web server is going to give you the cached version instead of doing useless operations. So if you call an API to get the list of users, the server will perform some calculations and give back the result, but the next same request ( if in the meantime the db didn't change ) you can just immediately serve a cached response.

Use compressed formats.

Images are really common in every website, unfortunately they can be really heavy compared to other web resources resulting in a bad user experience. The solution to this problem is to use the correct image format and size. Be sure you serve pictures in the JPEG2000 format and in the size your browser is going to render them.