CodeOverload
CodeOverload

Reputation: 48485

How to load jQuery if it's not already loaded?

I'm working on a weather widget, so in order to optimize it i want to check if jQuery has been loaded in the page, if Not, the widget will load it from my website. Because not all the websites use jQuery. how to do that?

Example of how to put my widget:

<html>
blah blah blah
.................
<script src="http://www.xxx.com/weather.js"></script>
</body>
</html>

Thank you

Upvotes: 0

Views: 733

Answers (1)

andres descalzo
andres descalzo

Reputation: 14967

if (typeof window["jQuery"] == "undefined"){

  // no jquery

}

Upvotes: 1

Related Questions