WordPress · infra · fg-0103

'wp.data is undefined' JavaScript error on pages using WP Rocket delay JS

If you see Uncaught TypeError from the inline wp-data-js-after script calling wp.data.use, the cause and the fix for WordPress are below, last verified 2026-08-17.

Staletrust 50/100

This trap has not been confirmed recently and may be out of date.

Symptom
Uncaught TypeError from the inline wp-data-js-after script calling wp.data.useSession replay tools flag a code error on every page view
Cause
Delay and defer reorder a core inline script so it runs before the script it depends on.
Fix
Dequeue the inline after-script on the front end if nothing there needs it, or exclude the dependency from delay.
Apply
$strip = function () { wp_scripts()->add_data('wp-data', 'after', []); }; add_action('wp_enqueue_scripts', $strip, 9999); add_action('wp_print_footer_scripts', $strip, 1); then confirm document.getElementById('wp-data-js-after') is null
Affected
WP Rocket delay JS, August 2026

Last verified 2026-08-17 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun