[jQuery] Re: Load JQuery only once

2008-11-24 Thread Raphael Jolivet

Hello, thanks to all of you.
Your 3 solutions are interesting.

I'll use the wordpress specific solution, but I remind the others for
future work.

I'm glad to see that the JQuery community is helpful and reactive.

Regards,

Raphael


[jQuery] Load JQuery only once

2008-11-20 Thread Raphael Jolivet

Hello,

I've developped several plugins for wordpress that require JQuery.
As I have packaged and distributed these plugins separately, they come
all with one version of JQuery.

The problem is that if someone uses two of these plugins, the HTML
header will look like :
script type=text/javascript src=http://mysite/plugin1/jquery.js;
/script
script type=text/javascript src=http://mysite/plugin1/
jquery.plugin1.js /script
script type=text/javascript src=http://mysite/plugin2/jquery.js;
/script
script type=text/javascript src=http://mysite/plugin2/
jquery.plugin2.js /script

There are two issues here :
* JQuery is loaded twice
* The plugin declared by plugin1 will be erased by the second load of
Jquery.js.

Can I load Jquery dynamically by testing it is not already loaded ?

I'm searching for a way to replace :

script type=text/javascript src=http/mysite/plugin1/jquery.js /
script

by

script type=text/javascript
if (!jquery_loaded) {
dynamic_load(http://mysite/plugin1/jquery.js;);
}
/script

Thanks in advance for your help.

Raphael