I typically see these accessed via a link statement in the . But I guess you can also upload the entire shiv, library, etc. to a directory on your server space, accessing them “locally” (at least local to your site, not pulling them from another location) as you probably do with your CSS files.
So which approach is better?
It kinda bothers me to rely on a 3rd-party like this. What if their site goes down? What if they change the directory structure and/or filename? Then the shiv or library you’re trying to use won’t be available. Is this a valid concern?
On the other hand, keeping these resources in directories of your site’s space means you’ll have to manually update them as never versions are released. And maybe there are space usage and/or bandwidth consequences.
The main reason to load stuff like jQuery from the Google CDN or similar places is that users that have visited a site which pulls the library from the same place wont have to download it again.
It’s less intensive bandwidth use for your website and your visitors will see faster load times, as 99% of them will already have it cached. There is no reason whatsoever to host your own version of jQuery, mootools, htmlshiv etc. I’d say that your concern about uptime on say Googles CDN is invalid :-)
Do both. The advantage to using a 3rd-party CDN is that many people will have visited a site that uses the same code from the same source and therefore has it cached by the browser – instant access, no download time.
Paul Irish, in the html5 boilerplate, uses this method:
edit// late to the punch, but I'll disagree with gno about not hosting your own version - just use the method above
@wolfcry911, The fallback method is indeed smart. But honestly, I cannot imagine a situation where it would be necessary. It’s a matter of preference – using the fallback is just overkill in my opinion.
I dont expect that any of the pages I’ve created will outlast the Google CDN. ;-)