Removing additional assets from plugin

Hi, I recently watch the screencast on gulp/bower and was trying to remove some plugin assets as shown in the screencast, but it simply didn’t work for me, I’m not sure what I’m missing.

I wanted to remove some of the assets from the eventOn plugin and following the screencast added this to my extras.php

function remove_plugin_assets() {
  wp_dequeue_style('eventOn');  // eventOn/assets/css/eventon_styles.css
  wp_dequeue_style('eventOn');  // eventOn/assets/fonts/font-awesome.css
  wp_dequeue_style('eventOn');  // eventOn/assets/css/eventon_dynamic_styles.css
  wp_dequeue_script('eventOn'); // eventOn/assets/js/eventon_script.js
  wp_dequeue_script('eventOn'); // eventOn/assets/js/maps/eventon_init_gmap.js
  wp_dequeue_script('eventOn'); // eventOn/assets/js/maps/eventon_gen_maps.js
add_action('wp_equeue_scripts', __NAMESPACE__ . '\\remove_plugin_assets');

However it did literally nothing, so I’m not sure what I’m missing.

You can’t pass the same handle eventOn every time and expect anything to happen. Your comments with the path to each file are ignored since they’re comments.

You need to go into the plugin and get the actual handle of each file being enqueued. You may also need to set a higher priority to that action to make sure it is run after eventOn has enqueued it’s files

Ah sorry I’m more of a designer than a dev. I was just going from the example in the screencast:

Could you possibly give me a clearer explanation of how I would structure it and set it as high priority please?

Yes, and that example works because the plugin being used enqueued the css and js with the handle roots-share-buttons.

You need to identify the handles for those assets.

EventOn is very complex, so dequeuing those might have some pretty strange results…

Most of the handles you seem to be referring to should be located in the file:


So from one of your item examples above:

wp_dequeue_style('eventOn');  // eventOn/assets/css/eventon_dynamic_styles.css

Instead you might use:

wp_dequeue_style( 'eventon_dynamic_styles');


( 'eventon_dynamic_styles');

…is the handle of the hook used to enqueue the stylesheet defined in the function that was used to register that file.

However, it also appears that many of the scripts/styles in EventOn have been included in arrays, with variables, so whatever you do may break all kinds of things…

Have you tried contacting the EventOn developers for help?

Thanks for the response :grinning:

Wish I could make it work even enough to break something haha, but still getting no result, I can’t tell if I’m still just using the wrong handle, but it looks right.

function remove_plugin_assets() {
  wp_dequeue_style('eventon_dynamic_styles');  // eventOn/assets/css/eventon_dynamic_styles'.css
add_action('wp_enqueue_scripts', __NAMESPACE__ . '\\remove_plugin_assets', 1);

1 will make your function run probably before the plugin has enqueued the file. Set it to something like 100

That didn’t make a difference unfortunately :confused:

I can get it to work with the Roots Share Buttons. So it may be a case of me contacting the plugin dev I suppose, unless anyone else can tell me another way to find the handles?

Solved it in the end. According to the plugin author of EventOn the classes are under “eventon/includes/class-frontend.php”, however to save other people the trouble of searching for every script/style in every plugin was able to find a plugin which can find them for you - minqueue - it hasn’t been updated for a while, but it works like a charm.

Thanks @kalenjohnson & @guy_b for your help :grinning:

EDIT I only use the minqueue plugin to identify styles & scripts enqueued on a page Not to concatenate & minify them, Sage already allows you to concat and minify styles/scripts by default. (Just a little disclaimer. Also thanks @ben for pulling me up on that I should have explained that originally)

Whoa, what? Do not use that plugin. Sage already has made it so you can concat and minify as many assets as you want.

It’s totally possible to dequeue the assets from the EventOn plugin.

I’m not actually using minqueue to concat or minify anything, I am doing that via sage. I’m only using minqueue to easily identify all the styles and scripts that are being loaded on the page and the class I need to use to dequeue them, which saves me from hunting through the plugin includes as the structure tends to vary a little from plugin to plugin.

The problem I had with EventOn was while I could dequeue all of the styles, it seemed like the only way to dequeue some of the js would be to edit the plugin, at least according to the plugin author. I didn’t want to do that because of updates, so in the end I’ve just used ACF to handle events.

I do like the EventOn plugin though so if you know how to properly dequeue all the scripts without editing the plugin, it would be awesome to know.

Also @benword if you know any wizardry to finding the right class names for enqueued styles/scripts without using a plugin, could you share please? :smile:

I know I’m late to the question, but there is a typo that might be playing a role. I copy/pasted for myself and it wasn’t working for me either. Try:

add_action('wp_enqueue_scripts', __NAMESPACE__ . '\\remove_plugin_assets');

Also, I’m not sure if this helps, but I found the functions used to enqueue scripts/styles in a plugin I’m using by searching the plugin directory for wp_enqueue_scripts. I hope that helps!

1 Like

Thanks for correcting that @geodee I’m sure some people will find that very helpful :grinning: