Skip to content

Commit 7abd9fe

Browse files
authored
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/
1 parent 5d759c9 commit 7abd9fe

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Actions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ public function maybe_register_assets() {
6060
Helpers::get_js_url( true ),
6161
'',
6262
$version,
63-
apply_filters( 'plausible_load_js_in_footer', false )
63+
[
64+
'in_footer' => apply_filters( 'plausible_load_js_in_footer', false ),
65+
'strategy' => 'defer',
66+
]
6467
);
6568

6669
// Goal tracking inline script (Don't disable this as it is required by 404).

0 commit comments

Comments
 (0)