Support » Plugin: WooCommerce » Why print_script_block_data used on every page?

  • Resolved freimaks

    (@freimaks)


    Hi!

    Recently I noticed that on every page the script “var wc_product_block_data = JSON.parse (decodeURIComponent (“.

    This script is output by the function print_script_block_data from woocommerce\packages\woocommerce-blocks\src\Assets.php.

    Why is this script needed?

    The problem is that I have a lot of categories and the script is just huge!

    Just for example, I copied the script code and saved it in a text file. File size over 500 kilobytes! Half a megabyte of incomprehensible code!)))

Viewing 5 replies - 1 through 5 (of 5 total)
  • I have this concern as well.

    In my case it’s only adding about 4kb on every page load, but it’s still mysterious and undesired just the same. Having it exist on WooCommerce-related pages is acceptable, but the problem is ALL non-WooCommerce pages seem to have this as well.

    Similarily, there’s many other WooCommerce scripts loaded on every non-WooCommerce page as well.

    This post is marked as resolved. is there a resolution?

    Yes -I am having the same issue with “var wc_product_block_data = JSON.parse (decodeURIComponent (“..

    This is being tagged by quttera as potential suspicious file… Any solution or reason why this code is necessary? Is this a result of the latest woocommerce update?

    Luke Cavanagh

    (@lukefiretoss)

    The change is new product blocks in WooCommerce 3.7.0 for the block editor.
    https://woocommerce.wordpress.com/2019/08/12/woocommerce-3-7-has-landed/

    I’m getting it as well and would like to know some php function to remove it

    jodhavishalsingh

    (@jodhavishalsingh)

    Hi, Use this in functions.php

    add_action('wp_footer','wooexperts_remove_block_data',0);
    add_action('admin_enqueue_scripts','wooexperts_remove_block_data',0);
    function wooexperts_remove_block_data(){ 
        remove_filter('wp_print_footer_scripts',array('Automattic\WooCommerce\Blocks\Assets','print_script_block_data'),1);
        remove_filter('admin_print_footer_scripts',array('Automattic\WooCommerce\Blocks\Assets','print_script_block_data'),1);
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.