I reference objects (images, scripts, iframes, etc) from other websites. Sometimes, the other site is down, and I have to wait about 30 seconds for my browser to “skip” the object. How can I “skip” the object after, for example, 5 seconds?
Here’s some sample code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.6.2.min.js"><\/script>')</script>
Check out yepnope. Here’s a snippet straight from its home page:
I suggest investigating yepnope and other existing script loaders before deciding whether to roll your own. These loaders are quite small (yepnope claims to be 1.6 kB), so there’s not much to gain by writing your own solution.