Forums

deregister gd-star rating on home page (3 posts)

  1. sangeetamevad
    Member
    Posted 8 months ago #

    hi my site is already running slow & i am not using gd-star on my home page so i want to deregister it, but confused how to deregister ?

    or i want to load script only when it’s needed, should check the content for the sign of present of the script.

    i used, but failed, still showing script in home page

    <?php wp_deregister_script('gd-star-rating','/wp-content/plugins/gd-star-rating/js/gdsr.js');?>
    <?php wp_deregister_style('gd-star-rating','/wp-content/plugins/gd-star-rating/css/gdsr.css.php');?>
  2. MickeyRoush
    Member
    Posted 3 months ago #

    I know this is old, but I had to do this the other day. So if anyone else wants to know how to deregister these on your home page, try the following below:

    add_action( 'wp_print_styles', 'deregister_gdsrstyles', 100 );
    function deregister_gdsrstyles() {
    	if ( is_front_page() ) {
    		wp_deregister_style( 'gdsr_style_main' );
    		wp_deregister_style( 'gdsr_style_xtra' );
    	}
    }
    
    add_action( 'wp_print_scripts', 'deregister_gdsrscript', 100 );
    function deregister_gdsrscript() {
    	if ( is_front_page() ) {
    		wp_deregister_script( 'gdsr_script' );
    	}
    }
  3. karaloko
    Member
    Posted 3 weeks ago #

    Hey staff, thanks for the code I'm using and is a beauty.

Reply

You must log in to post.

About this Topic