javascript - How to load local files if CDN is not working -
i using cdn js , css files.
i searched in google how load local data if cdn not working.
i found link written this
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript"> if (typeof jquery == 'undefined') { document.write(unescape("%3cscript src='js/plugins/jquery-1.8.2.min.js' type='text/javascript'%3e%3c/script%3e")); } </script>
yes working tried cdn network ,then not downloading local. if cdn not working showing error in page , page not working due missing js file. means :
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script> <script type="text/javascript"> if (typeof jquery == 'undefined') { document.write(unescape("%3cscript src='include/js/jqueryplugin/jquery.min.js' type='text/javascript'%3e%3c/script%3e")); } </script>
in above case local jquery.min.js not downloading when above cdn not working .
similarly how css(searched in google , not found solution).
how know cdn not working , download respective files local.
please help
thanks in advance
you can use scripts below:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script> window.jquery || document.write('<script src="/scripts/jquery.1.9.1.min.js"><\/script>')</script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script> <script> window.jquery.ui || document.write('<script src="/scripts/jquery-ui.min.js"><\/script>')</script>
hope usefull!
Comments
Post a Comment