• Resolved sp20011981

    (@sp20011981)


    Hi guys,

    if someone can help about how to disable

    var wc_product_block_data = JSON.parse( decodeURIComponent(

    Thanks,
    S.

    • This topic was modified 5 years, 3 months ago by sp20011981.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Так же интересует эта проблема. На некоторых сайтах код большого размера, в 10 раз больше чем весь остальной код.

    Edit the file located at: /wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Assets.php

    Lines 146 – 148:
    <!– <script type=”text/javascript”>
    var wc_product_block_data = JSON.parse( decodeURIComponent( ‘<?php echo rawurlencode( wp_json_encode( $block_settings ) ); ?>’ ) );
    </script>–>

    I had to do this to not get flagged for malware on Google Ads as all of the % signs in the rendered code are suspected as javascript injection. I have not noticed any issues with the site since doing this.

    Specifically:
    HTML JavaScript code JavaScript virus injection Reason: long string Code: %7B%22min_columns%22%3A1%2C%22max_columns%22%3A6%2C%22default_columns%22%3A3%2C%22min_rows%22%3A1%2C
    HTML JavaScript code JavaScript virus injection too many %

    Hello @nmbgeek
    I hope you are well.
    Can you please explain what you changed the code to and what the results should be (will it stop the loading of unnecessary code? Will it break the site content?).
    The only difference I see in your code and the code in the file is this at the beginning: <!–
    followed by this at the end:
    –>

    For me I’m trying to speed up my site and noticed all this loading (312kb when saved as text file), originally I was looking to why youtube iframe.api is loading on a page where there is no embedded video and came across:
    var wc_product_block_data = JSON.parse( decodeURIComponent(
    which showed me many instances of the youtube iframe and other things that I was not expecting. any insights you have regarding this would be grand.

    Thanks kindly
    Simon

    • This reply was modified 5 years, 2 months ago by sy19.
    • This reply was modified 5 years, 2 months ago by sy19.

    is there a way to do this without editing the source files? such as a function you can put in your themes functions. editing the source file is just going to be redundant as you’ll have to edit it everytime you update woocommerce

    Plugin Support AW a11n

    (@slash1andy)

    Automattic Happiness Engineer

    Hey there!

    Since this is a few weeks old, and about customization, I am going to mark as resolved. A lot of people have found help in the Advanced WooCommerce group with things like this, so I would recommend checking there, or we highly recommend contacting one of the services on our Customizations page (https://woocommerce.com/customizations/)

    Vikram S.

    (@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);
    }

    Thank you @jodhavishalsingh — confirmed your solution works.

    Thank you @jodhavishalsingh for the working function.

    Thank you @jodhavishalsingh !
    Would you mind sharing what is the reason for that data block and what does your code do? (so that we know what we are doing) Does it affect anywhere else? (is this because of Gutenberg blocks stuff?)

    And this guy (last comment) has another code to remove that, what’s the difference:
    remove_action( 'admin_print_footer_scripts', array( 'WC_Block_Library', 'print_script_settings' ), 1 );

    Thank you in advance!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Disable / remove var wc_product_block_data = JSON.parse( decodeURIComponent(’ is closed to new replies.