Hacker News new | ask | show | jobs
by digitalclubb 5059 days ago
It's interesting and slightly scary the CDN issue. Several months ago when there was an issue with Google's CDN, an awful lot of websites fell over as they never had a local backup in place.

Hopefully as jQuery usage grows people come to understand the need for fallbacks.

1 comments

especially when it's trivial to implement

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
    <script type="text/javascript">
    if (typeof jQuery == 'undefined') { document.write(unescape("%3Cscript src='/path_to_scripts/js/libs/jquery-1.8.0.min.js' type='text/javascript'%3E%3C/script%3E"));}
    </script>
Is it really that big of a perf hit to just download the minified and use it in your source like all other libs? jq isn't that big of beast, plus if you have a large site its cached for every other page visit :)
> if you have a large site its cached for every other page visit

until you modify your own js (not that rare and uncommon) and it's back new and shiny again. from the cdn, it's just already there sitting in the browser's cache.

> Is it really that big of a perf hit

maybe not, but if you had the option to wake up with your teeth already brushed, wouldn't you take it? :D

You don't need to use unescape in the fallback

    if(!jQuery)document.write('<script src="jquery.js"></scrip'+'t>');