Search code examples
javascriptjqueryhtml5shiv

Check if html 5 shim is loaded


We generally check if jQuery is loaded from CDN or not and fallback to local version if it didnt.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>

I am using twitter bootstrap, and it loads the html 5 shim from the googlecode copy.

<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>

Is there any way I can fallback to local version if it does not load from googlecode

Or am I doing something wrong. Shouldnt be I checking this ?


Solution

  • <script>window.html5 || document.write('<script src="js/libs/your-local-version.js"><\/script>')</script>