1

There's a similar question here but mine is a little more specific in regarding speicific scripts and that I'm going to use a CDN regardless.

Jsdeliver allows you to combine several script into one.

For example I can add jquery and jquery migrate like this: https://cdn.jsdelivr.net/g/jquery@1.11.3,jquery.migrate@1.3.0

From a speed standpoint is it better to load widely used scripts separately since it may already be cached even if they are from different domains? Or to combine them on the same cdn domain even if it's certain they won't be cached?

There may not be a definite answer on this...

Google's jQuery is used the most so would it always be smarter to load it from Google even if I'm using a different cdn form my other scripts?

Pagespeed insights tells you to load your scripts together from one url, but to me, it seems possible that this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> 
<script src="https://cdn.jsdelivr.net/jquery.migrate/1.3.0/jquery-migrate.min.js"></script>

Might still be better than this just because jquery is probably already cached:

<script src="https://cdn.jsdelivr.net/g/jquery@1.11.3,jquery.migrate@1.3.0"></script>
Community
  • 1
  • 1
Bryan Willis
  • 3,552
  • 1
  • 25
  • 34

1 Answers1

0

Well the less Request you make the better and combining the scripts together you will reduce your requests.

On the other hand as you said you will have to load even cached scripts and more traffic and more cdn usage and for what, 1-2 less requests?

do not merge all the scripts load the popular ones separately and merge the others.

Try to reduce somewhere else like combining images and making spirit images and ...

Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171