Scenario:
I'd like to load the jQuery and jQuery UI lib from Google's CDN but if they take too long to load, then retrieve it from the local web server.
I'm using Coldfusion but I don't think that is the answer. I think I need to do something with JavaScript.
I wrapped my script src tags with cftry but that did not work.
<cftry>
<!-- Load Jquery from Google -->
<script src=".7.0/jquery.min.js"></script>
<script src=".8.16/jquery-ui.min.js"></script>
<link rel="stylesheet" href=".8.16/themes/<cfoutput>#css_style#</cfoutput>/jquery-ui.css" type="text/css" media="all" />
<cfcatch type="any">
<!-- load from local server -->
<script src="assets/jQuery/jquery-1.7.2.min.js"></script>
<script src="assets/jQueryUI/js/jquery-ui-1.8.7.custom.min.js"></script>
<link rel="stylesheet" href="assets/jQueryUI/css/<cfoutput>#css_style#</cfoutput>/jquery-ui-1.8.7.custom.css" type="text/css" media="all" />
</cfcatch>
</cftry>
Scenario:
I'd like to load the jQuery and jQuery UI lib from Google's CDN but if they take too long to load, then retrieve it from the local web server.
I'm using Coldfusion but I don't think that is the answer. I think I need to do something with JavaScript.
I wrapped my script src tags with cftry but that did not work.
<cftry>
<!-- Load Jquery from Google -->
<script src="https://ajax.googleapis./ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="https://ajax.googleapis./ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis./ajax/libs/jqueryui/1.8.16/themes/<cfoutput>#css_style#</cfoutput>/jquery-ui.css" type="text/css" media="all" />
<cfcatch type="any">
<!-- load from local server -->
<script src="assets/jQuery/jquery-1.7.2.min.js"></script>
<script src="assets/jQueryUI/js/jquery-ui-1.8.7.custom.min.js"></script>
<link rel="stylesheet" href="assets/jQueryUI/css/<cfoutput>#css_style#</cfoutput>/jquery-ui-1.8.7.custom.css" type="text/css" media="all" />
</cfcatch>
</cftry>
Share
Improve this question
edited Apr 26, 2012 at 14:51
HPWD
asked Apr 26, 2012 at 14:05
HPWDHPWD
2,2404 gold badges32 silver badges64 bronze badges
2 Answers
Reset to default 6<script type="text/javascript" src="//ajax.googleapis./ajax/libs/jquery/1.8.3/jquery.js"></script>
<script type="text/javascript">window.jQuery || document.write("<script type='text/javascript' src='js/jquery-1.8.3.min.js'>\x3C/script>")</script>
-- corrected mixed quotes in statement. Dreamweaver reported a syntax error until that was corrected --
<script>
setTimeout(function() {
if(window.jQuery) return;
var n = document.getElementsByTagName("script")[0];
n.parentNode.insertBefore(document.createElement("script"), n).src = "assets/jQuery/jquery-1.7.2.min.js";
}, 5000);
</script>
<script src="https://ajax.googleapis./ajax/libs/jquery/1.7.0/jquery.min.js"></script>