New Landing How can we help? Themeforest Theme Support Dante Deregister Revolution Slider scripts

Viewing 12 posts - 1 through 12 (of 12 total)
  • Posted in: Dante
  • #195669
    Kauf
    Member
    Post count: 22

    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 );
    
    #195674
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    Why don’t you deactivate the plugin? that’s the best way.

    -Rui

    #195677
    Kauf
    Member
    Post count: 22

    I 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 );
    #195682
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    in 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

    #195686
    Kauf
    Member
    Post count: 22

    Hi 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.

    #195688
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Try 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

    #195693
    Kauf
    Member
    Post count: 22

    Still no luck. Do I have the correct $handle?

    #195696
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    better 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

    #195715
    Kauf
    Member
    Post count: 22

    Hi 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 );
    }
    #195718
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    It 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

    #195737
    Kauf
    Member
    Post count: 22

    Looks good.

    Thanks a lot for the help.

    #195739
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    No problem. Glad I could help.
    -Rui

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register