Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hi krievinshj

    wishlist styles and scripts are loaded everywhere because plugin works with shortcode, and you can add shortcodes potentially to every page in your wordpress installation

    Anyway, if you know that this assets are not needed, you can use wp/wc conditional functions, to conditionally dequeue scripts/styles

    I.E, you can add this code at the end of functions.php file of your theme

    function dequeue_wishlist_assets(){
    	if( ! is_shop() && ! is_product() && ! is_product_category() && ! is_page( get_option( 'yith_wcwl_wishlist_page_id' ) ) ){
    		remove_action( 'wp_enqueue_scripts', array( YITH_WCWL_Init(), 'enqueue_styles_and_stuffs' ) );
    		remove_action( 'wp_enqueue_scripts', array( YITH_WCWL_Init(), 'enqueue_scripts' ) );
    	}
    }
    add_action( 'wp', 'dequeue_wishlist_assets', 99 );

    Let me know if this helps
    Have a nice day ??

    Thread Starter krievinshj

    (@krievinshj)

    Thanks a lot!!!
    It worked perfectly!

    Plugin Author YITHEMES

    (@yithemes)

    Hi again krievinshj

    Glad to hear good news ??

    If you have appreciated our plugin and our help, please don’t forget to give us a 5-star vote, and consider buying our premium version: here you can find more information about it, and here you can try a live demo of the plugin. ??

    Marking this as resolved
    Have a nice day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Conditionally load scripts and styles’ is closed to new replies.