0

What better - Jquery file from my SERVER or from URL? <script src="jquery.js"></script> or

<script src='http://code.jquery.com/jquery-1.7.1.min.js'></script>

  • QUESTION and Answer already exist -> http://stackoverflow.com/questions/3475024/whats-the-difference-between-jquery-js-and-jquery-min-js – CodeLove Oct 23 '15 at 09:37
  • **[Read this post](http://encosia.com/3-reasons-why-you-should-let-google-host-jquery-for-you/)** – Guruprasad J Rao Oct 23 '15 at 09:38

1 Answers1

-1

All too often, I find code similar to this when inspecting the source for public websites that use jQuery:

<script type="text/javascript" src="jQuery.min.js"></script>

If you’re doing this on a public facing website, you are doing it wrong.

Instead, I urge you to use the Google Hosted Libraries content delivery network to serve jQuery to your users directly from Google’s network of data centers. Doing so has several advantages over hosting jQuery on your server(s): decreased latency, increased parallelism, and better caching.

Better use this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
Hussy Borad
  • 626
  • 5
  • 20
  • Thank you, I have one more question. If I need to load Jquery for lot of pages in my site, there is a way to load it once? – Rotem Lanyado Oct 23 '15 at 09:55
  • No. that not possible. But you can try this for. **Fall back to local in case the CDN isn't available** – Hussy Borad Oct 23 '15 at 10:01
  • it'll be cached after first occurrence. So not to worry about that. – Ashwini Agarwal Oct 23 '15 at 10:01