Raphael, I often use something like this to test and then dynamically
load the jquery library:

try
{
        //simple statement to see if jquery has already been loaded
        jQuery('body').addClass('jqueryPage');
}
catch(err)
{
        var scriptObj = document.createElement("script");
        scriptObj.src = "jquery-1.2.6.pack.js";
        scriptObj.type = "text/javascript";
        var head=document.getElementsByTagName('head')[0];
        head.insertBefore(scriptObj,head.firstChild);
}

On Nov 21, 11:16 am, Raphael Jolivet <[EMAIL PROTECTED]>
wrote:
> 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

Reply via email to