• Resolved Gal Baras

    (@galbaras)


    Since not all pages show swatches, plugin resources should only be loaded when they are needed. If “Load scripts globally” means they are loaded on every page, this will result in unused JavaScript, which is not good.

    If it means something else, please elaborate.

Viewing 2 replies - 1 through 2 (of 2 total)
  • @galbaras

    Please try the filter. The first filter allows you to load files on the product and the second filter loads CSS on the product page and category pages.

    add_filter( 'disable_wvs_enqueue_scripts', function(){
    // Load only product page. Return true to disable.
    return ! is_product();
    
    } );
    
    //Or
    
    add_filter( 'disable_wvs_enqueue_scripts', function(){
    
    // Load only shop or product page. Return true to disable.
    return ! (is_product() || is_shop());
    
    } );

    Previously, we try to load the swatches elements where the WooCommerce Variation script loads. But page builder does the difference to show the swatches anywhere on the site. So, we have to take this decision.

    Thank You

    • This reply was modified 5 years, 3 months ago by pluginswoo.
    • This reply was modified 5 years, 3 months ago by pluginswoo.
    Thread Starter Gal Baras

    (@galbaras)

    @pluginswoo Thank you for the filters, but I think the default should be only to load on product pages, and changing this global loading should be a setting, not a filter.

    Also, you can add detection of shortcodes, blocks, etc that require resources and load them then.

    Performance is very important these days, and reducing performance for many sites that don’t use page builders takes them back a step.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘What does “Load scripts globally” mean?’ is closed to new replies.