I’ve been doing a few extensions lately that require jQuery. If I have 3-4 of these extensions all installed at once, and they all have a setting to locate your jQuery file, doesn’t that get hit 3-4 times? There’s a couple new ones I want to release, but not until I figure out how to keep these lean.
What’s the best practice way to check if a script has already been called on the page? I want these extensions to say “Is there a reference to jQuery yet? If not, then use the path established in your settings to find it”.
Oh Oh Me Me!!!!!
What about?
if (typeof jQuery != 'undefined'){
script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'jquery.js';
document.getElementsByTagName('head')[0].addChild(script);
}
I haven’t tested it but I’m sure it would work. You may have issues wit different versions of jQuery still
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.