Support » Plugins and Hacks » [Resolved] Script handle naming convention

[Resolved] Script handle naming convention

  • @all,

    As a plugin maintainer/dev I have come across some cases where several plugins include the same script or javascript library extension but register it with a different handle name with wp_register_script() or wp_enqueue_script()

    This will result in the same script (not the same file) being loaded twice when these plugins are used in combo. Sometimes it might even cause a js conflict.

    In one of my plugins I am using wp_deregister_script() to de-register possible instances of the same script just before registering the version included in my plugin package. I do this for several of the handle names that I have seen the same script being registered with in other plugins. Although this prevents most cases of the same script being loaded twice (or more) there are several disadvantages:
    1. This only works if I make sure I hook into enqueue_scripts with this wp_deregister_script stuff after all other plugins have done their thing;
    2. This might cause problems if by doing so, I accidentally de-register a script that (although registered under a similar name) has another function or is of another version;
    3. This will cause problems when the de-registered script handle is used as a dependency for another script. In this case, although the same script is re-registered, it is done so under different name and WP will drop the enqueueing of the new script that is dependant on the first one.

    Other cases might be possible, I imagine.

    So my question is: is there any naming convention for script handles when registering them in WP?

    Just picking three examples from the list on

    Official script file name » Script file in WP » Handle name
    jquery-1.6.2.js » jquery.js » jquery
    jquery-ui-1.8.min.js » ui.core.js » jquery-ui-core
    jquery.form.js » jquery.form.js » jquery-form
    jquery.schedule.js » jquery.schedule.js » schedule
    tiny_mce.js » tiny_mce.js » tiny_mce

    … does not give me a clear picture at all…

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Script handle naming convention’ is closed to new replies.