Commit aafbdd3129d for woocommerce
commit aafbdd3129de330be4d110955b9a635861fe50af
Author: Dat Hoang <htdat@users.noreply.github.com>
Date: Fri Sep 4 21:52:49 2026 +0700
Revert "Move tokenization form script to footer with defer strategy" (#68379)
* Revert "Move tokenization form script to footer with defer strategy (#68036)"
This reverts commit d4600233b44b206ddf16ee48c0d3544ea9d7c880.
* changelog
diff --git a/plugins/woocommerce/changelog/68036-woopmnt-6354-tokenization-form-footer b/plugins/woocommerce/changelog/68036-woopmnt-6354-tokenization-form-footer
deleted file mode 100644
index fd786269be5..00000000000
--- a/plugins/woocommerce/changelog/68036-woopmnt-6354-tokenization-form-footer
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: performance
-
-Load `woocommerce-tokenization-form` in the footer with a `defer` strategy so the script no longer sits in the blocking `<head>` on checkout pages.
diff --git a/plugins/woocommerce/changelog/revert-pr-68036 b/plugins/woocommerce/changelog/revert-pr-68036
new file mode 100644
index 00000000000..d0beae8ce2b
--- /dev/null
+++ b/plugins/woocommerce/changelog/revert-pr-68036
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Revert PR #68036, see WOOAIRR-226
diff --git a/plugins/woocommerce/client/legacy/js/frontend/tokenization-form.js b/plugins/woocommerce/client/legacy/js/frontend/tokenization-form.js
index c204f6c7870..23fe862069f 100644
--- a/plugins/woocommerce/client/legacy/js/frontend/tokenization-form.js
+++ b/plugins/woocommerce/client/legacy/js/frontend/tokenization-form.js
@@ -1,5 +1,5 @@
/*global wc_tokenization_form_params */
-( function( $ ) {
+jQuery( function( $ ) {
/**
* WCTokenizationForm class.
@@ -105,12 +105,6 @@
/**
* Initialize.
- *
- * Register the listener synchronously (outside jQuery(fn)) so it is bound before
- * any DOM-ready callback runs. With this script loaded in the footer with a
- * defer strategy, wc-credit-card-form-init is fired from another script's
- * DOM-ready callback and would otherwise be missed if we deferred registration
- * until our own DOM-ready callback ran later in the queue.
*/
$( document.body ).on( 'updated_checkout wc-credit-card-form-init', function() {
// Loop over gateways with saved payment methods
@@ -120,4 +114,4 @@
$( this ).wc_tokenization_form();
} );
} );
-} )( jQuery );
+} );
diff --git a/plugins/woocommerce/includes/abstracts/abstract-wc-payment-gateway.php b/plugins/woocommerce/includes/abstracts/abstract-wc-payment-gateway.php
index 710483e400b..5ed2e4394e2 100644
--- a/plugins/woocommerce/includes/abstracts/abstract-wc-payment-gateway.php
+++ b/plugins/woocommerce/includes/abstracts/abstract-wc-payment-gateway.php
@@ -566,10 +566,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
plugins_url( '/assets/js/frontend/tokenization-form' . ( Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min' ) . '.js', WC_PLUGIN_FILE ),
array( 'jquery' ),
WC()->version,
- array(
- 'in_footer' => true,
- 'strategy' => 'defer',
- )
+ false
);
wp_localize_script(