• Resolved Paul

    (@paulschiretz)


    Hi,

    I noticed for some time now, that the moment i enable “Use Global Site Tag” the woocommerce analytics integration enqueues some polyfills:

    wp-polyfill-inert.js
    regenerator-runtime.js
    wp-polyfill.js

    Can you tell me why they are needed? I’m not a big fan of polyfills, any way to dequeue them if they are not needed?

    And, yes they are from your plugin(the only active on except woocommerce on my test site) and yes i did an exclusion test with storefront as theme. ??


    All the best,
    Paul

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @paulschiretz

    The polyfills you mentioned – wp-polyfill-inert.js, regenerator-runtime.js, and wp-polyfill.js are scripts that provide compatibility on older browsers that do not natively support it. They are used to ensure that the features of the WooCommerce Analytics Integration work seamlessly across different browsers and versions, including those that might not support the latest JavaScript features.

    The “Use Global Site Tag” option in WooCommerce uses Google’s gtag.js for its analytics, which requires these polyfills for full compatibility. This is why they are enqueued when you enable this option.

    Thread Starter Paul

    (@paulschiretz)

    Hi,

    thanks for the answer ?? i agree, according to the google docs the last 2 versions of every modern browser are supported without the need for polyfills. Right, thats not enough for every use-case. For my use-case it would be ok to miss the analythics data of users with older browsers, cause it will not make them unable to use my site and tracking users is not mission critical for my business. Is there a way to dequeue the polyfills?

    All the best, Paul

    Plugin Support nicw.a11n

    (@nicw)

    Hi @paulschiretz

    Polyfills are indeed a source of much discussion among WordPress developers at the moment – but it’s not an easy debate: witness the ongoing discussion about polyfills and Gutenberg itself.

    The plugin does not declare a need for the polyfills, nor does it enqueue them – these are added by core WordPress. The plugin does require jQuery to be loaded. I cannot see a specific way to dequeue the polyfills, except by approaching it from a core WordPress angle.

    No guarantees, but something like this works on my test site, but possibly with unexpected side-effects (see the Gutenberg discussion above). Use at your own risk ??

    function deregister_polyfill(){
    
      wp_deregister_script( 'wp-polyfill' );
      wp_deregister_script( 'regenerator-runtime' );
    
    }
    add_action( 'wp_enqueue_scripts', 'deregister_polyfill');
    
    Thread Starter Paul

    (@paulschiretz)

    Hi @nicw,

    Thanks for the answer, i was just curious about this. Thanks also for the link to the tickets and the deregister code. I will play around with it a little on my test install.

    All the best,
    Paul

    Plugin Support nicw.a11n

    (@nicw)

    Hi @paulschiretz

    It’s a pleasure. Thanks for marking as resolved.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Polyfills enqueued’ is closed to new replies.