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…
- The topic ‘Script handle naming convention’ is closed to new replies.