[wp-hackers] wp_register_script() vs. wp_enqueue_script()?

Otto otto at ottodestruct.com
Fri Jan 23 01:11:28 GMT 2009

On Thu, Jan 22, 2009 at 12:15 AM, Mike Schinkel
<mikeschinkel at newclarity.net> wrote:
> So using enqueue *can* achieve the same register with the addition of also emitting the link into the header. If I misunderstand please let me know otherwise it's what I assumed would make sense.

Yes, enqueue does indeed do the same thing as a register if the script
is not already registered.

> But that would only help *if* different plugins used the same name, right?  So three different plugins could register "Nifty Corners"[1] respectively  each as the following and they would all three get included, right?
>   1.) wp_register_script('niftycorners', ...);
>   2.) wp_register_script('nifty-corners', ...);
>   3.) wp_register_script('nifty_corners', ...);
> Hence my suggestion to have a single place to list how they are used...?

I see your point, but in truth it probably doesn't come up all that
often. It would be better to establish a set of guidelines for handle
naming conventions. If we go by core, then here's what I see:

1. Lowercase.
2. Use the exact name of the script. Same as the js file, preferably.
3. Multiple words get their spaces/periods replaced by dashes.
"nifty-corners" would be correct.
4. Separately loadable parts of packages (jquery, scriptaculous) get a
prefix of the name of the package, followed by the name of the
individual piece. jquery-form, jquery-color, etc.

And so on.

More information about the wp-hackers mailing list