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="https://d3js.org/d3.v6.min.js"></script>
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.
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.