To confirm that cdn script loaded you can check for existence any variable/function this script defines, if it is undefined - then cdn failed and you need to load local script copy.
On this principle are based solutions like that:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.5.1.min.js">\x3C/script>')</script>
(if there is no window.jQuery property defined cdn script didn't loaded).
<\/script>
works fine, too.
if (typeof(window.jQuery) === 'undefined') document.write('<script src="js/libs/jquery-1.5.1.min.js"><\/script>')
'Programming' 카테고리의 다른 글
(JSP) WAS 정보 얻기 (0) | 2013.09.02 |
---|---|
10 Javascript Performance Boosting Tips from Nicholas Zakas (0) | 2013.09.02 |
HTML Textbox Input Tooltip? (0) | 2013.08.29 |
How to delete file in Java (0) | 2013.08.26 |
C# Language Specification Version 5.0 (0) | 2013.08.25 |