Minimising JavaScript and CSS for better SEO results

Fast loading times have become so important that it really comes down to the details now. Speed is […]

· 2 min read· Jaap van Duijn

Fast loading times have become so important that it really comes down to the details now. Speed is a ranking factor in Google. We’ve written about this before in optimising images. That’s usually where the biggest gains can be made, but minimising JavaScript and CSS is the next step in the process. How do you go about it?

Use libraries wisely

Examples of libraries include jQuery and Bootstrap. These are comprehensive sets of functionality that allow you to get a website up and running quickly and, on the face of it, effectively. They often contain so much code that you don’t even use most of it. When developing a new website, front-end developers like to use libraries, as this means they can create anything they want. Once the website has been launched, all that unnecessary CSS and JavaScript remains in place. To ensure fast loading times, you should only keep the scripts that are actually used and remove the rest. Web browsers load everything, including all the unnecessary scripts. You can significantly reduce loading times by removing those unnecessary scripts.

How do you remove unnecessary CSS and JavaScript?

If Google can detect which JavaScript and CSS lines aren’t being used, then anyone can do it! Chrome Console features the Coverage tab, which allows you to see, for each JavaScript and CSS file, which lines are used and which are not. You can go through this line by line and remove the unnecessary lines, but that’s quite a painstaking task. By using WebPack When publishing the web project, can you leave the JavaScript and CSS bundelen (merge all files), splitten (= any unnecessary lines will then be removed) and comprimeren (= removing unnecessary whitespace). The end result is then a single JavaScript file and a single CSS file, each containing only the code that is actually used.

In the event of future expansions – in the case of WebPack – you, as a front-end developer, can continue to make full use of all the benefits of libraries within the development environment. As soon as the changes go live, the splitter determines which JavaScript and CSS are relevant at that moment. Properly structuring the web project from the outset ensures that you continue to deliver a high-quality solution.

Defer and Async

If you’re not exactly a Node.js expert, you can always use the attributes for JavaScript files defer and async add. This tells web browsers when to load the specific file. When defer the scripts are loaded once the web page has loaded. When async it loads immediately. Browsers want to understand exactly what you, as a web developer, are trying to achieve. Any lack of clarity leads to a loss of speed. Ultimately, it is the website visitors who are most affected by this.

Google prefers to direct visitors to a user-friendly website, which is why a website with fast loading times pays off. Do you want to get more out of your website too? Then get in touch with SEO Ninja straight away.