Skip to content

Commit 4fa1490

Browse files
authored
Merge pull request #255 from plausible/fix_wp_rocket_delay_js
Fixed: exclude our loaded JS from WP Rocket's delay JS setting.
2 parents 41cd238 + b1a3f72 commit 4fa1490

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Compatibility.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public function __construct() {
5959
add_filter( 'rocket_exclude_js', [ $this, 'exclude_plausible_js' ] );
6060
add_filter( 'rocket_minify_excluded_external_js', [ $this, 'exclude_plausible_js' ] );
6161
add_filter( 'rocket_delay_js_exclusions', [ $this, 'exclude_plausible_inline_js' ] );
62+
add_filter( 'rocket_delay_js_exclusions', [ $this, 'exclude_by_proxy_endpoint' ] );
6263
add_filter( 'rocket_exclude_defer_js', [ $this, 'exclude_plausible_js_by_relative_url' ] );
6364
}
6465
}
@@ -126,6 +127,20 @@ public function exclude_plausible_js_by_relative_url( $excluded_js ) {
126127
return $excluded_js;
127128
}
128129

130+
/**
131+
* Dear WP Rocket/SG Optimizer/Etc. don't minify/combine/delay our API endpoint, please.
132+
*
133+
* @param $excluded_js
134+
*
135+
* @return mixed
136+
* @throws Exception
137+
*/
138+
public function exclude_by_proxy_endpoint( $excluded_js ) {
139+
$excluded_js[] = Helpers::get_rest_endpoint( false );
140+
141+
return $excluded_js;
142+
}
143+
129144
/**
130145
* Dear WP Rocket/SG Optimizer/Etc., don't minify/combine/delay our external JS, please.
131146
*

0 commit comments

Comments
 (0)