From 7abd9fefbb9cb9961eea497948c3fef940fce9aa Mon Sep 17 00:00:00 2001 From: Josh Betz Date: Mon, 3 Mar 2025 20:55:40 -0600 Subject: [PATCH] feat: defer plausible-analytics script Since WordPress 6.3, we've been able to defer scripts. The plausible-analytic script is a good candidate for this. https://make.wordpress.org/core/2023/07/14/registering-scripts-with-async-and-defer-attributes-in-wordpress-6-3/ --- src/Actions.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Actions.php b/src/Actions.php index 257f1ff..77110f7 100644 --- a/src/Actions.php +++ b/src/Actions.php @@ -60,7 +60,10 @@ public function maybe_register_assets() { Helpers::get_js_url( true ), '', $version, - apply_filters( 'plausible_load_js_in_footer', false ) + [ + 'in_footer' => apply_filters( 'plausible_load_js_in_footer', false ), + 'strategy' => 'defer', + ] ); // Goal tracking inline script (Don't disable this as it is required by 404).