Loading jQuery multiple times in the same page
Posted
by
Winaji
on Stack Overflow
See other posts from Stack Overflow
or by Winaji
Published on 2011-01-17T09:45:38Z
Indexed on
2011/01/17
10:53 UTC
Read the original article
Hit count: 170
I'm implementing a plug-in that's embeddable in different sites (a la Meebo, Wibiya), and I want to use jQuery. Problem is, the site I'm embedding to, may already have a jQuery script loaded.
The question is, what's the best approach for this kind of problem:
Should I just check if jQuery is already loaded and if so, use the original site's jQuery, otherwise load it myself? If I use this approach, am I not risking comaptibility problems (i.e. the site uses an old version of jQuery)?
Should I load jQuery myself (whether it's already loaded or not) and call "jQuery.noConflict(true)" when it's finished loading? If so, how can I make sure that my jQuery has finished loading (hooking to the onLoad event doesn't seem to work all the time, and polling for "jQuery" won't work for obvious reasons)?
Should I do something else?
Thanks.
© Stack Overflow or respective owner