Saturday, 25 May 2013

Add a script as a dependency to a registered script

Add a script as a dependency to a registered script

wp_register_script() (see codex) allows you to specify dependencies: scripts that must be loaded before the one being registered is loaded (if it is loaded).
But suppose the script is a third-party one (WordPress or another plug-in) so that you are not the one calling wp_register_script(). How can you inject a script as a dependency for a pre-registered script?
Remarks: In my particular use-case the dependency is not strict - the registered script does not require this second script, but the latter alters the original script.
A similar question could be asked for styles, but I suspect the answers would be nearly identical.

No comments:

Post a Comment