Hi there,
I am trying to dequeue this script:
<script type="text/javascript" src="http://ffd-web.com/wp/wp-content/plugins/so-widgets-bundle/js/jquery.cycle.min.js?ver=1.7.1"></script>
Because I need to replace it with a specific tweaked version that won’t resize the slider on window.resize, unless the width delta is more than +-90px. I need this because I use to resize the Hero Widget according to window.height via a script, and I have to prevent a bad UX experience on mobile browsers due to the toggling browser address bar that always changes window.height, triggering window.resize events.
I’ve found the handlers in baseslider.class.php, and I’ve tried to dequeue them in this way, putting this code in function.php of my theme (based on _S):
function baseslider_fix() { // include needed to let is_plugin_active work on theme's function.php include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); if(is_plugin_active('so_widgets_bundle')) { //dequeue scripts wp_dequeue_script('sow-slider-slider'); wp_deregister_script('sow-slider-slider'); wp_dequeue_script('sow-slider-slider-cycle2'); wp_deregister_script('sow-slider-slider-cycle2'); //enqueue scripts wp_enqueue_etcetera.... (still have to write code) } } add_action( 'init', 'baseslider_fix', 100 );
However, it won’t work. I’ve tried other hooks, such as widget_init, after_theme_setup, wp_enqueue_scripts etc etc with priotity set up to 1000, tried to remove the if condition, removed the function wrapper, using wp_dequeue o wp_deregister alone, but nothing seems to trigger the script removal…
What should I change in my code? Where should I hook my action?
Thanks
Hi Frafor,
We don’t actually output the scripts until the_content. You should remove them after that point. Something like this will work:
Thanks alex, I will try later ;)