• Hello,

    I just installed the plugin and am enjoying the features. Unfortunately I’ve had to disable the plugin as I’ve noticed it’s loading 5 files across all my products:

    JAVASCRIPT:
    ‘cwginstock_js-js’
    ‘sweetalert2-js’
    ‘cwginstock_popup-js’

    CSS:
    ‘cwginstock_frontend_css-css’
    ‘cwginstock_bootstrap-css’

    Other plugins I use, like wpforms, use conditional loading of the files only on the pages that need them, to optimize the load time of the site, especially after Google’s Core Vitals update.

    I’ve tried adding the products I want to show the form on under the “Show/Hide Subscribe Form for specific products” setting in the backend, but this still loads the 5 files above on all my products, even the digital ones that are always in stock.

    How can I load the above 5 files ONLY on the products that I want this plugin to show a subscribe form on when they are out of stock?

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support CodeWooGeek Support

    (@codewoogeeksupport)

    Hello there,

    Good Day!!

    Thank you for your detailed report, and we appreciate it.

    We want to inform you that your feedback has been duly noted and forwarded to our core team for consideration. They will assess the feasibility of implementing these suggestions and strive to incorporate them into our upcoming versions.

    Thanks.

    Thread Starter Soprano

    (@soprano)

    Thank you for taking in the feedback. I’ve tried using this code to dequeu the scripts but it doesn’t seem to do the job:

    add_action('wp_print_scripts', 'conditional_remove_backorder_js');
    function conditional_remove_give_js() {
    if ( !is_product( array( 3181, 999 ) ) ) {
    wp_dequeue_script( 'cwginstock_js-js' );
    wp_dequeue_script( 'sweetalert2-js' );
    wp_dequeue_script( 'cwginstock_popup-js' );
    }
    }
    
    add_action('wp_print_styles', 'conditional_remove_backorder_css');
    function conditional_remove_give_css() {
    if ( !is_product( array( 3181, 999 ) ) ) {
    wp_dequeue_style( 'cwginstock_frontend_css-css' );
    wp_dequeue_style( 'cwginstock_bootstrap-css' );
    }
    }

    I’m happy to pay for an addon if you release it as such, but I was hoping to find a solution to this soon. Any estimates to when this may be released as a feature?

    @soprano – try using

    wp_dequeue_script( 'cwginstock_js' );
    wp_dequeue_script( 'sweetalert2' );
    wp_dequeue_script( 'cwginstock_popup' );

    instead. That worked for me.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Conditionally loading the 5 plugin assets on specific pages’ is closed to new replies.