Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
416 views
in Technique[技术] by (71.8m points)

javascript - Can using multiple libraries from a CDN slow down my site speed?

I'm new to web development and I'm using multiple libraries for different purposes on my site. Can using all these libraries slow down my site's speed ??? Thanks!

Libraries used:

  • fontawesome
  • Jquery
  • animejs
  • smoothScrool
  • select2
  • etc

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

They could if you have a lot of them.

  • Large numbers of parallel requests (say, more than 8 at once) may be throttled
  • If there's a large amount of code in the libraries, there's a lot of data to transfer. On slower connections, having to transfer large amounts of data before the site is functional is a problem.

To mitigate some of these issues, consider consolidating all the libraries into a single script file that you bundle together using a module bundler like Webpack. In addition, make sure to use tree shaking to remove code that will never be used, and also minify the code for production so that the least amount of code needs to be sent over the network as possible. You can also consider waiting to load the non-essential libraries (like smooth scrolling) until the libraries required for the site to be functional are ready.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...