Grow your CSS skills. Land your dream job.

html5shiv, JavaScript Libraries, etc: a question

  • # June 1, 2011 at 8:09 am

    Just wondering about the best way to use 3rd-party resources like Google’s html5 shiv, jquery, other JavaScript libraries, and so on.

    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.

    What do you folks think?

    # June 1, 2011 at 9:14 am

    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 :-)

    # June 1, 2011 at 9:16 am

    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

    # June 1, 2011 at 9:36 am

    @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. ;-)

    # June 1, 2011 at 3:45 pm

    Thanks for the feedback, folks. Sounds like my concerns were groundless.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".