Heavy libraries

What is a JavaScript library ?

A library is a third-party resource embedded in the page containing JavaScript code. It provides a set of additional functionality to the browser. The integration of the library is done through the HTML <script> tag.

For example, the D3.js library allows you to create different types of graphics very quickly.

<script src=""></script>

Why is it important that they are lightweight ?

Heavy JavaScript libraries can result in poor performance because they consume a lot of browser resources when they are interpreted and increase the network loading required to download them. For this reason, it is worth using lightweight libraries to improve page loading and interactivity time.

What to do with heavy libraries ?

When a library has a lighter alternative, or one that offers less functionality but fulfills the usefulness that you make of it, it is interesting to replace it. Replacing a JavaScript library is not something trivial since you have to intervene in the code, and modify all the calls using the old library for the new one.

For example, the "Moment" library, which allows you to manipulate dates, can be replaced by "dayjs", which lightens the weight of the page by 69Ko.