1.Too many interactions with the host
2.Too many dependencies
3.Poor event handling
3. Ways to optimize JS:
1.Eliminate render-blocking resources:
Use online tools (https://jscompress.com/) or plugins to minify JS files.
3.Limit library dependencies:
Library dependencies add a lot to loading times, so strive to keep their use to a minimum, and avoid them entirely if at all possible. One way to reduce your dependency on external libraries is to rely more on in-browser technology.
4.Prefer Async and Defer:
If you want script tags to load asynchronously, or to defer until the rest of the page has finished loading, you can add the async or defer attributes:
// load example.js without interrupting your webpage’s rendering
<script src=”example.js” async></script>
// load example.js after the page has finished loading
<script src=”example.js” defer></script>