DEV Community

Cover image for Should we use CDN to load JavaScript plugins?
Tomoya Kuroda
Tomoya Kuroda

Posted on

Should we use CDN to load JavaScript plugins?

Yes! It's much faster than getting the files from your server.

To enhance loading speed, I learned that reducing the amount of HTTP requests is preferable. So, I grabbed a number of JavaScript plugins, including Bootstrap and GSAP, and integrated them into a single huge file. However, loading the JavaScript file on a live server took roughly 10 seconds 😥.

I examined the Network tab, and caching does not appear to be working. So I changed my strategy and started using CDN for JavaScript plugins, and the page loaded in only a few seconds.

Although the performance will vary depending on your server's specifications and settings, I advocate using CDN to load JavaScript plugins because they are automatically cached and will not be downloaded again when users reload the same page or visit other pages.

Top comments (0)