8

I am using jQuery, angular, bootstrap, along with some custom js files. Currently, I have everything bundled into one script. Since, jQuery, angular, and bootstrap are available via CDN, is it better to just grab them from the CDN or should I keep those bundled with my scripts?

5
  • Better by what metric?
    – Neil
    Jul 29, 2015 at 13:48
  • @Neil - In general, but I would say speed and size?
    – xaisoft
    Jul 29, 2015 at 13:52
  • 1
    Combining the files reduces the number of requests, which can speed download. Pulling the files from a CDN that is widely used improves the chance that the files will already be present in the user's cache from visiting other sites. If they haven't, though, they'll get slowed down from additional DNS and HTTP requests. ` Jul 29, 2015 at 14:00
  • Most people tend to prefer bundling, as you don't depend on another server being up to work and you only have to download a single script once.
    – Neil
    Jul 29, 2015 at 14:30
  • I ran across this answer and felt it explains bundling well stackoverflow.com/a/28233712/32240
    – Ray
    Oct 7, 2016 at 4:29

1 Answer 1

3

My advice would be to bundle all of your own scripts together, and load common third party scripts from a CDN. It gives you the best of both worlds - your scripts download quickly, and third party scripts are likely loaded directly from the end user's cache.

1
  • 3
    Just a suggestion. Have a copy of these scripts in your repository otherwise you are totally dependent of CDN content management. Same goes for any js lib you might been using. Js ecosystem is quite fragil and volatile.
    – Laiv
    Nov 16, 2016 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.