To increase page speed am using Google CDN to download jquery file and I also have fall back to download jquery from local incase Google CDN fails.
Below is how am using fallback
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
document.write(unescape("%3Cscript src='common/script/jquery-1.9.1.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
Above code works perfect, my question is how to check if jquery migrate file is loaded or not?
All I need is to check if http://code.jquery.com/jquery-migrate-1.1.0.js is loaded or not. I hope if (typeof jQuery == 'undefined') {} this wont work here.
Any solutions
You can check for the existance of $.fn.live
method or jQuery.migrateWarnings
object
<script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.1.0.min.js"></script>
<script type="text/javascript">
if (typeof jQuery.migrateWarnings == 'undefined') { // or typeof jQuery.fn.live == 'undefined'
document.write(unescape("%3Cscript src='common/script/jquery-migrate-1.1.0.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With