if you're using jquery

Started by rcjordan, March 29, 2013, 10:11:11 PM

Previous topic - Next topic

rcjordan

are you hosting it or linking out to jquery.com?

Torben

When I'm not hosting it I use Google

jetboy


rcjordan

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>


rcjordan

Noticeable speed improvement by switching to google vs jquery hosting. 

ergophobe

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

Drastic


bill

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.

Rooftop

We usually serve it from Google as well.