I need to check if I need to load JQuery OR it is already loaded by another page !?
How can I check this on client side ? I want to have something like this:
<script >
if jquery-1.6.2.js isExist then
{return}
else // somehow
load (<script src="../js/jq/jquery-1.6.2.js"></script> )
</script>
I need to check if I need to load JQuery OR it is already loaded by another page !?
How can I check this on client side ? I want to have something like this:
<script >
if jquery-1.6.2.js isExist then
{return}
else // somehow
load (<script src="../js/jq/jquery-1.6.2.js"></script> )
</script>
Share
Improve this question
asked Dec 15, 2011 at 23:53
EmaxEmax
1,0473 gold badges13 silver badges16 bronze badges
2 Answers
Reset to default 6This example from modernizr trays to load jquery from the google cdn if it fails it loads local jquery. Your code may be similar.
<script src="//ajax.googleapis./ajax/libs/jquery/1.6.1/jquery.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.6.1.min.js">\x3C/script>')</script>
<div id="loader"></div>
<script>
if (!window.jQuery) {
var e = document.createElement('script'); e.async = true;
e.src = '../js/jq/jquery-1.6.2.js';
document.getElementById('loader').appendChild(e);
}
</script>