Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Dante › Deregister Revolution Slider scripts
New Landing › How can we help? › Themeforest Theme Support › Dante › Deregister Revolution Slider scripts
- This topic has 11 replies, 2 voices, and was last updated 9 years by Rui Guerreiro – SUPPORT.
-
Posted in: Dante
-
July 17, 2015 at 2:42 pm #195669
Dear Support Team,
I need to deregister the scripts for Revolution slider for personal reasons, I have tried this script below and it doesn’t work. Please how do I fix this?
function denqueue_scripts_revslider() { wp_dequeue_script( 'jquery.themepunch.tools.min' ); wp_deregister_script( 'jquery.themepunch.tools.min' ); wp_dequeue_script( 'jquery.themepunch.revolution.min' ); wp_deregister_script( 'jquery.themepunch.revolution.min' ); } add_action( 'wp_enqueue_scripts', 'denqueue_scripts_revslider', 100 );
July 17, 2015 at 2:51 pm #195674Hi,
Why don’t you deactivate the plugin? that’s the best way.
-Rui
July 17, 2015 at 2:57 pm #195677I need the scrips deregisted only on certain pages or on mobile for example in the code below
function denqueue_scripts_revslider_mobile() { if ( wp_is_mobile() ) { wp_dequeue_script( 'jquery.themepunch.tools.min' ); wp_deregister_script( 'jquery.themepunch.tools.min' ); wp_dequeue_script( 'jquery.themepunch.revolution.min' ); wp_deregister_script( 'jquery.themepunch.revolution.min' ); } } add_action( 'wp_enqueue_scripts', 'denqueue_scripts_revslider_mobile', 100 );
July 17, 2015 at 3:09 pm #195682in that case it needs to be conditional use the id’s of the pages where you want to deactivate it.
function denqueue_scripts_revslider_mobile() { wp_dequeue_script( 'jquery.themepunch.tools.min' ); wp_deregister_script( 'jquery.themepunch.tools.min' ); wp_dequeue_script( 'jquery.themepunch.revolution.min' ); wp_deregister_script( 'jquery.themepunch.revolution.min' ); } if ( wp_is_mobile() && ( is_page( 42 ) || is_page( 38 ) ) ){ add_action( 'wp_enqueue_scripts', 'denqueue_scripts_revslider_mobile', 100 ); }
Give it a try
-Rui
July 17, 2015 at 3:20 pm #195686Hi Rui,
Thanks for the reply. I tried, doesn’t work. Actually tried that before 😀
Is there some other way to implement this or maybe I did something wrong. I use the dante child theme and I have this in the functions.php file.
July 17, 2015 at 3:24 pm #195688Try this way instead, sometimes the code is correct the problem is where it is executed(hook)
function denqueue_scripts_revslider_mobile() { if ( wp_is_mobile() && ( is_page( 42 ) || is_page( 38 ) ) ){ wp_dequeue_script( 'jquery.themepunch.tools.min' ); wp_deregister_script( 'jquery.themepunch.tools.min' ); wp_dequeue_script( 'jquery.themepunch.revolution.min' ); wp_deregister_script( 'jquery.themepunch.revolution.min' ); } } add_action( 'wp_enqueue_scripts', 'denqueue_scripts_revslider_mobile', 100 );
-Rui
July 17, 2015 at 3:38 pm #195693Still no luck. Do I have the correct $handle?
July 17, 2015 at 3:46 pm #195696better to remove the mobile condition for now, not sure if that works fine.
also try to echo something just to be sure the function is executed or not.function denqueue_scripts_revslider_mobile() { if ( is_page( 42 ) || is_page( 38 ) ){ var_dump("testing"); wp_dequeue_script( 'jquery.themepunch.tools.min' ); wp_deregister_script( 'jquery.themepunch.tools.min' ); wp_dequeue_script( 'jquery.themepunch.revolution.min' ); wp_deregister_script( 'jquery.themepunch.revolution.min' ); } } add_action( 'wp_enqueue_scripts', 'denqueue_scripts_revslider_mobile', 100 );
-Rui
July 17, 2015 at 4:31 pm #195715Hi Rui,
Yes you’re absolutely right, it’s a little trick on mobile. I managed with the code below, works on my local, not quite sure if it’s appropriate and should push to production
function denqueue_scripts_revslider_mobile { $output .= '<script> $(document).ready(function () { revapi1.bind("revolution.slide.onloaded",function (e) { revapi1.revkill(); }); }); </script>'; echo $output; } if ( wp_is_mobile() ) { add_action( 'wp_footer', 'denqueue_scripts_revslider_mobile', 100 ); }
July 17, 2015 at 4:40 pm #195718It looks fine great, but that gave me an idea. When you are in mobile it’s added 1 class to the body called mobile-browser
maybe this jQuery can also sort it , you can put it in the js custom option in the theme options
jQuery(document).ready(function () { jQuery('body').hasClass('mobile-browser'){ revapi1.bind("revolution.slide.onloaded",function (e) { revapi1.revkill(); }); } });
just in case it’s necessary.
-Rui
July 17, 2015 at 5:48 pm #195737Looks good.
Thanks a lot for the help.
July 17, 2015 at 5:51 pm #195739No problem. Glad I could help.
-Rui -
Posted in: Dante
You must be logged in and have valid license to reply to this topic.