From 32d2eaa0355a8f85d44c7c673b20f0384e916d63 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Fri, 14 Mar 2025 11:08:13 -0400 Subject: [PATCH 1/2] refactor: Register `jetpack-connection` scripts absolutely Reverts: - https://github.com/Automattic/jetpack/pull/39604 - https://github.com/Automattic/jetpack/pull/39870 Conditional registration was added to address *perceived* performance issues, rather than *actual* performance issues. While enqueueing assets comes at a network cost, registration should not, in theory, incur such cost. Registration is light-weight operation. Conditionally registered assets are problematic as they are difficult to query globally. If an asset is conditionally registered within a specific context, it will be unavailable outside of that context. E.g., a REST API endpoint is unable to query an asset conditionally registered with WP Admin. --- projects/packages/connection/actions.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/projects/packages/connection/actions.php b/projects/packages/connection/actions.php index a25f876be32c..486d29dad0ef 100644 --- a/projects/packages/connection/actions.php +++ b/projects/packages/connection/actions.php @@ -5,11 +5,6 @@ * @package automattic/jetpack-connection */ -if ( function_exists( 'is_admin' ) && ! is_admin() && ( ! defined( 'IS_WPCOM' ) || ! IS_WPCOM ) ) { - // Don't initialize the assets in the frontend on self-hosted and WoA. - return; -} - // If WordPress's plugin API is available already, use it. If not, // drop data into `$wp_filter` for `WP_Hook::build_preinitialized_hooks()`. if ( function_exists( 'add_action' ) ) { From 78cbdb61526af69a789d93e45daefa1790d4a2ba Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Fri, 14 Mar 2025 11:22:13 -0400 Subject: [PATCH 2/2] changelog --- .../changelog/register-jetpack-connection-scripts-absolutely | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/packages/connection/changelog/register-jetpack-connection-scripts-absolutely diff --git a/projects/packages/connection/changelog/register-jetpack-connection-scripts-absolutely b/projects/packages/connection/changelog/register-jetpack-connection-scripts-absolutely new file mode 100644 index 000000000000..04ce7d8eb0d1 --- /dev/null +++ b/projects/packages/connection/changelog/register-jetpack-connection-scripts-absolutely @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Connection: register assets absolutely