The Core

Why We Are Here => Hardware & Technology => Topic started by: rcjordan on March 29, 2013, 10:11:11 PM

Title: if you're using jquery
Post by: rcjordan on March 29, 2013, 10:11:11 PM
are you hosting it or linking out to jquery.com?
Title: Re: if you're using jquery
Post by: Torben on March 30, 2013, 08:08:34 AM
When I'm not hosting it I use Google
Title: Re: if you're using jquery
Post by: jetboy on March 30, 2013, 09:58:32 AM
Hosting it. What the best approach is doesn't have a simple answer: http://www.stevesouders.com/blog/2013/03/18/http-archive-jquery/
Title: Re: if you're using jquery
Post by: rcjordan on March 30, 2013, 12:35:18 PM
Mostly, I'm thinking that using a cdn will take advantage of a user's cached copy re loading speed.  After I posted here I pointed my cms template to jquery.com rather than my hosted copy and my pages rendered OK but the bootstrap jquery-dependent responsive nav hung for an unacceptable amount of time. So, if I do go hosted I'll follow Torben's lead and use Google.

Below is a 2009 suggestion from stackoverflow that switches the call for the js to local should G fail.  Seems like a good idea.

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript">
if (typeof jQuery == 'undefined')
{
    document.write(unescape("%3Cscript src='/path/to/your/jquery' type='text/javascript'%3E%3C/script%3E"));
}
</script>

Title: Re: if you're using jquery
Post by: rcjordan on March 30, 2013, 06:08:20 PM
Noticeable speed improvement by switching to google vs jquery hosting. 
Title: Re: if you're using jquery
Post by: ergophobe on March 31, 2013, 09:55:18 PM
You could do it like the HTML5 Boilerplate project - first try Google (or other CDN) and then fall back to local if Google fails to load (or the other way around for that matter).


    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script>window.jQuery || document.write('<script src="path/to/local/jquery-1.9.1.min.js"><\/script>')</script>



Some chatter RE this method

http://www.1stwebdesigner.com/design/snippets-html5-boilerplate/
http://stackoverflow.com/questions/5014040/fallback-for-jquery-ui-from-google-cdn
Title: Re: if you're using jquery
Post by: Drastic on April 01, 2013, 02:19:35 PM
Quote from: Torben on March 30, 2013, 08:08:34 AM
When I'm not hosting it I use Google

Same here.
Title: Re: if you're using jquery
Post by: bill on April 02, 2013, 04:59:15 AM
Quote from: Drastic on April 01, 2013, 02:19:35 PM
Quote from: Torben on March 30, 2013, 08:08:34 AM
When I'm not hosting it I use Google

Same here.
ditto.

I tried self-hosting, but the Google can't be beat for speed.
Title: Re: if you're using jquery
Post by: Rooftop on April 02, 2013, 01:36:53 PM
We usually serve it from Google as well.