[wp-hackers] Accessing jQuery in Core for a plugin

Otto otto at ottodestruct.com
Mon Nov 10 20:31:18 GMT 2008


It's just that simple. You need to do it before wp_head though.
Preferably on the init action hook.

Alternatively, if your own JS depends on jquery, then you can enqueue
your own script with a dependancy on jquery:
wp_enqueue_script('newscript', plugins_url('yourplugin/newscript.js',
array('jquery'), '1.0' );

See: http://codex.wordpress.org/Function_Reference/wp_enqueue_script

On Mon, Nov 10, 2008 at 1:21 PM, ade <ade at studiograsshopper.ch> wrote:
> Hi all,
> I'm writing a plugin around a jQuery script and I'm trying to understand how best to access jQuery which, if I understand correctly, is included in the Wordpress core files.
> My question is this: in my plugin, how do I register my js script to use the core jQuery? Am I right in thinking I use wp_register_script within an init function? Or do I use wp_enqueue_script? And if I use the latter, will this prevent jQuery being loaded twice if it is already called by another installed plugin? Yes, I'm confused. :-)
> If there isn't a quick and easy answer, a link to any articles out there would be much appreciated.
> Thanks!
> Ade.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list