[wp-hackers] wp_register_script() vs. wp_enqueue_script()?
gaarai at gaarai.com
Wed Jan 21 17:47:18 GMT 2009
Technically, you never have to register anything if you don't want to.
The register functions are there and can be valuable if you want a
central location that defines scripts and styles that will be used in
your plugin/theme. You can then simply use the enqueue functions while
referring to just the handle in order to enqueue the script or style for
inclusion in the head.
So, the main purpose of the register functions is to allow you to
simplify your code by removing the need to duplicate code if you enqueue
the same script or style in more than one section of code. The benefits
of this are many and probably don't need to be listed here.
Mike Schinkel wrote:
> Hi all:
> When, if ever, should I call wp_register_script() vs. just calling wp_enqueue_script()? The same question applies to the *_style() versions as well.
> Is wp_register_script() just something to call in core WP to create shortcuts for standard scripts/styles?
> Thanks in advance.
> -Mike Schinkel
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers