Freelancer.com

Go Back   Warrior Forum - The #1 Internet Marketing Forum & Marketplace > Warrior Support Forums > Programming
Register Blogs Social Groups Advertise with usHelp Desk

View Poll Results: Do you/should you load jQuery from Google CDN?
From Google is fine 3 42.86%
From jQuery's own site 1 14.29%
My own hosting is better 3 42.86%
What is jQuery? 0 0%
Voters: 7. You may not vote on this poll

Reply
LinkBack Thread Tools
Unread 23rd January 2013, 05:47 PM   #1
HyperActive Warrior
 
Happy_Balance's Avatar
 
Join Date: 2009
Posts: 181
Thanks: 26
Thanked 20 Times in 15 Posts
Default Do you/should you load jQuery from Google CDN?

If you load jQuery from the local server there is no chance of waiting for the 3rd party site, but little chance the end-user already has it cached in their browser.

Some people are convinced getting it "free" from Google is faster, others say "can be extremely slow", and there is also the option of getting it from jQuery's site.

Does anyone know if the jQuery.org CDN uses Amazon web services, and/or do they have a "perfect record" of up-time?

Every Day Is Fun! :)
Happy_Balance is offline   Reply With Quote
Unread 23rd January 2013, 06:31 PM   #2
O.G. Warrior Member
 
oldschoolwarrior's Avatar
 
Join Date: 2010
Posts: 60
Thanks: 13
Thanked 8 Times in 8 Posts
Default Re: Do you/should you load jQuery from Google CDN?

I was just creating a php javascript loader, and found that the using googles compressor, really is slow.

Closure Compiler Service

Was talking about 30 seconds to load, and minimize code.
I download jquery, and ran it though my own php loader, to use caching and gz compressions, and it works great now!
oldschoolwarrior is offline   Reply With Quote
Unread 23rd January 2013, 07:13 PM   #3
Social Apps Made Easy
War Room Member
 
FirstSocialApps's Avatar
 
Join Date: 2012
Location: Mooresville, NC
Posts: 914
Thanks: 234
Thanked 260 Times in 216 Posts
Default Re: Do you/should you load jQuery from Google CDN?

I load it from Google. There is a good chance that the user all ready has it cached.

FirstSocialApps is offline   Reply With Quote
Unread 24th January 2013, 10:00 AM   #4
Warrior Member
 
Join Date: 2012
Posts: 13
Thanks: 0
Thanked 1 Time in 1 Post
Default Re: Do you/should you load jQuery from Google CDN?

I load jQuery from Google's CDN, but with a local fallback in the odd event that Google's copy doesn't load. The following is a model of what I have in my HEAD. I load the script from CDN first, then immediately check if jQuery is defined. If it's not, then my local fallback loads. Probably not the best fallback solution, but it works for me.

Code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
<script>window.jQuery||document.write('<script src="http://yourdomain.com/path/to/jquery.js"></script>')</script>
Tony Martinez is offline   Reply With Quote
Unread 24th January 2013, 10:39 AM   #5
Software Engineer
War Room Member
 
wayfarer's Avatar
 
Join Date: 2008
Location: Asheville, NC USA
Posts: 684
Thanks: 37
Thanked 110 Times in 98 Posts
Default Re: Do you/should you load jQuery from Google CDN?

Just load it from Google. If it's good enough for Twitter, it's good enough for me.

I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
wayfarer is offline   Reply With Quote
Unread 25th January 2013, 07:25 AM   #6
Enlivan
War Room Member
 
Damien Roche's Avatar
 
Join Date: 2007
Location: Outside The Box
Posts: 1,012
Thanks: 153
Thanked 103 Times in 71 Posts
Default Re: Do you/should you load jQuery from Google CDN?

Just to offer another option, I minimise and concatenate all javascript (and css) into a single js/css file.

>> Available For Full-Time Web Development <<

(HTML, CSS, JavaScript, PHP, Ruby, Rails)
Seasoned freelancer w/ established Elance profile
$50/hr
Damien Roche is offline   Reply With Quote
Unread 27th January 2013, 01:25 AM   #7
Software Product Creator
War Room Member
 
SteveSRS's Avatar
 
Join Date: 2012
Location: NL & Peru & USA
Posts: 456
Blog Entries: 5
Thanks: 44
Thanked 153 Times in 89 Posts
Default Re: Do you/should you load jQuery from Google CDN?

depends if you are using your own CDN...

If yes don't... only creates extra DNS request which is a bad thing..
If no.. depends test it.. I actually usually load it from my own domain.

SteveSRS is offline   Reply With Quote
Unread 28th January 2013, 01:59 PM   #8
WSO Fan
War Room Member
 
Don Art's Avatar
 
Join Date: 2011
Location: Petoskey, Michigan
Posts: 30
Thanks: 11
Thanked 14 Times in 13 Posts
Default Re: Do you/should you load jQuery from Google CDN?

No question you should load from Google (second choice from jquery).

Do not load from your host.

Here's why with proof:

if your visitor's browser follows http1.1 recs it will only open 2 simultaneous connections to any one host name at a time - so multiple hostnames is actually better:

"Clients that use persistent connections SHOULD limit the number of simultaneous connections that they maintain to a given server. A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy. A proxy SHOULD use up to 2*N connections to another server or proxy, where N is the number of simultaneously active users. These guidelines are intended to improve HTTP response times and avoid congestion."

Loading content from multiple hosts is generally better for another reason, if a server is slowish, content is still able to be fetched via the connections to the other specified hosts.


From Yahoo's Performance Best Practices:

"Reducing the number of unique hostnames has the potential to reduce the amount of parallel downloading that takes place in the page. Avoiding DNS lookups cuts response times, but reducing parallel downloads may increase response times. "

Note too: The issue of dns lookup time is mitigated by the fact that the user or user's ISP is extremely likely to have cached the ajax.googleapis.com domain. More from the same source:

"DNS lookups are cached for better performance. This caching can occur on a special caching server, maintained by the user's ISP or local area network, but there is also caching that occurs on the individual user's computer. The DNS information remains in the operating system's DNS cache (the "DNS Client service" on Microsoft Windows). Most browsers have their own caches, separate from the operating system's cache. As long as the browser keeps a DNS record in its own cache, it doesn't bother the operating system with a request for the record."

Next:

CDN technology is seriously robust and proven. Google's tech is 2nd to none. It's entire business depends on their CDN.

Google uses it's massive CDN to deliver content from servers worldwide. There will be an edge server closer (therefore probably faster) to your visitor than your own server is likely to be.

Finally and I think most decisive:

The user's browser is exceedingly likely to have already cached Google's copy of jquery from a previous visit to one of the millions of sites using Google's hosted apis. This means the browser will just load a local copy - far faster than any network access.
Don Art is offline   Reply With Quote
Unread 20th February 2013, 01:28 AM   #9
HyperActive Warrior
 
Happy_Balance's Avatar
 
Join Date: 2009
Posts: 181
Thanks: 26
Thanked 20 Times in 15 Posts
Default Re: Do you/should you load jQuery from Google CDN?

Quote:
Originally Posted by Don Art View Post
N
if your visitor's browser follows http1.1 recs it will only open 2 simultaneous connections to any one host name at a time - so multiple hostnames is actually better:
...
Good point about multiple hostnames, I should remember to load some images from a sub-domain.

Every Day Is Fun! :)
Happy_Balance is offline   Reply With Quote
Unread 20th February 2013, 04:34 AM   #10
ResponsiveDesignTest.Net
Registered Member
 
Michael71's Avatar
 
Join Date: 2011
Location: Rostock, Germany
Posts: 828
Thanks: 106
Thanked 223 Times in 193 Posts
Default Re: Do you/should you load jQuery from Google CDN?

Depends on the files you are loading after jQuery.

I prefer minifying/combining all JS files into one file.

In that case you just need one http-request and that's from your own domain.
Will save DNS lookup and time, same with CSS.

HTML/CSS/jQuery/ZURB Foundation/Twitter Bootstrap/Wordpress/Frontend Performance Optimizing
---
Need HTML/CSS help? Skype: microcosmic - Test Your Responsive Design - InternetCookies.eu
Michael71 is offline   Reply With Quote
Unread 20th February 2013, 02:42 PM   #11
App Developer
War Room Member
 
AppDeveloper's Avatar
 
Join Date: 2013
Location: San Francisco, CA
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
Default Re: Do you/should you load jQuery from Google CDN?

I agree with the others suggesting loading it from Google.

The vast majority of people will have it cached via that url. I don't have specific numbers, but with the number of sites linking to the Google version, I would be surprised if less than 95% of your visitors didn't have it cached.

And the ones that don't have it cached are going to most likely load it quicker from Googles CDN than from your server.

Combining all your JS files into one request is definitely a good idea, however, when that file gets too large (greater than ~64k) it makes sense to split it up into two files. If the rest of your included JS libraries are large then this can add up quickly. Modern web browsers will download multiple JavaScript files in parallel. So having two 60k files will download faster than one 120k file.

I develop Apps for Marketers
RubyDeveloper.com
AppDeveloper is offline   Reply With Quote
Reply

  Warrior Forum - The #1 Internet Marketing Forum & Marketplace > Warrior Support Forums > Programming

Bookmarks

Tags
cdn, google, jquery, load, you or should

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 05:19 AM.