Hi, what process are you currently implementing to dequeue the css and js files? Do you have a cache plugin installed?
Hi thanks for your replay,
I am using wp_dequeue_script and wp_dequeue_style functions to remove the 2 css files and the 2 javascript files.
In the source code, the files are referred like this:
<link rel='stylesheet' id='swpm.common-css' href='http://carrier/thewines/wp-content/plugins/simple-membership/css/swpm.common.css?ver=4.5.2' type='text/css' media='all' />
<link rel='stylesheet' id='validationEngine.jquery-css' href='http://carrier/thewines/wp-content/plugins/simple-membership/css/validationEngine.jquery.css?ver=4.5.2' type='text/css' media='all' />
<script type='text/javascript' src='http://carrier/thewines/wp-content/plugins/simple-membership/js/jquery.validationEngine-en.js?ver=4.5.2'></script>
<script type='text/javascript' src='http://carrier/thewines/wp-content/plugins/simple-membership/js/jquery.validationEngine.js?ver=4.5.2'></script>
Here’s what’s in my functions.php file:
function remove_vendor_scripts () {
wp_deregister_style( 'dashicons' );
wp_dequeue_script( 'swpm.common-css' );
wp_dequeue_script('validationEngine.jquery-css');
}
add_action('wp_enqueue_scripts', 'remove_vendor_scripts');
1. The css files have handlers: swpm.common-css and validationEngine.jquery-css, so I am passing them as arguments for the wp_dequeue_styles() function, but this doesn’t affect the page.
2. The javascript files don’t have handlers, so I am not sure which is the best way to refer to them for the wp_dequeue_scripts function.
Currently I don’t have any cache plugin installed.
Thanks again.
Michal
Thank you Michal for sharing the code and information. This will help the plugin developers to assess your issue further.
Regards
All of our front-end JS and CSS files are loaded using the following hook:
wp_enqueue_scripts
So you should be able to dequeue them. It is likely that your custom call is happening at a wrong time of the site’s page load execution (meaning it is being ineffective at intercepting it).
You can inspect the following function of our plugin’s code to see how we are using enqueue to load those files.
File: classes/class.simple-wp-membership
Function: common_library()
That function is executed using the WordPress’s wp_enqueue_scripts hook.
Thanks wp.insider! Yes, I just now managed to dequeue the js files so I can add them directly in my build. However for some reason the css files are not dequeued. I probably miss something. Here’s the piece of code out of the function.php file:
function remove_membershop_calls() {
/* Remove Simple membership js and css */
wp_dequeue_script( 'jquery.validationEngine-en' );
wp_dequeue_script('jquery.validationEngine');
wp_dequeue_style( 'swpm.common-css' );
wp_dequeue_style('validationEngine.jquery-css');
}
add_action( 'wp_enqueue_scripts', 'remove_membershop_calls', 20 );
Any idea what am I doing wrong?
Thanks again, and in advance.