There is a plugin that's conflicting with mine when the user loads the admin pages of my plugin, therefore I want to deregister and remove the conflicting script on these pages.

Here is the code for the conflicting script:-

add_action( 'admin_head', 'function_name' );

function function_name() {
if ( is_admin() ) {
        plugins_url('/js/some_javascript_file.js', __FILE__ )

So In my code I check to see if the user is in our admin pages and if so I try to deregister the script as follows:-

function admin_hc_deregister_conflicts() {

add_action('admin_head', array($this,'admin_hc_deregister_conflicts'),11);

The problem is that the script is still being loaded in my admin area causing a lot of problems!

Please can someone advise:-

i) Is it possible to remove a script that has been enqueued but not registered? ii) What can I add to my plugin to remove this script from being loaded in our admin pages so that there are no conflicts?

Thanks in advance!

  • Is it not possible to code around the conflict, i.e., since you know there's a conflict, make your code take it into account and work around it. I ask because it's not obvious if your plugin is for public consumption or just for you.
    – akTed
    Jan 7, 2013 at 17:24
  • That is likely not a good solution in this case. The conflicting plugin is being a bad citizen by enqueueing scripts admin-wide rather than directly where they need to be. If those scripts are used admin-wide, then It's up to Paul here to code around the conflicts. Jan 7, 2013 at 17:31
  • 2
    a registered script is... registered, an enqueued script is registered and then enqueued, technically either dequeueing or deregistering should work, and does in fact work when I test it. it's also worth noting that admin_head is the wrong action to enqueue a script, but there's nothing you can do about that!
    – Milo
    Jan 7, 2013 at 17:35
  • I missed in the Question "our" admin pages. So if by that you mean option pages for your plugin, I stand corrected. Dequeue-ing should work.
    – akTed
    Jan 7, 2013 at 17:43

2 Answers 2


Yep, it's possible, but you want to use wp_dequeue_script.

Try this:

function admin_hc_deregister_conflicts()
  • Thanks! Strangely, the script is still being loaded in my admin pages. Perhaps it's something to do with the order in which the scripts are being loaded? UPDATE: I was being a muppet: my hooked pages weren't working correctly - this works fine now! Jan 7, 2013 at 17:59

See wp_dequeue_script. Keep in mind that you might be breaking functionality of the offending plugin, which is bad form (even if said plugin is poorly written).

It's up to the end user to decide if a (possibly) badly coded plugin is worth using, and you (however well-intentioned) "fixing" another's plugin through yours might only make yours look bad in the end. Most users don't care why something works or doesn't.

  • Thanks, yes I wouldn't usually attempt to deregister another author's script - but this particular script is loaded admin wide when it should only be loaded on its own admin pages and thus causing conflicts in my admin area Jan 7, 2013 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.