Commit 484acd5
committed
Script Loader: Defer single-page admin init until DOMContentLoaded.
The Connectors and Font Library admin screens register a `-prerequisites`
classic-script handle with an empty `src` and attach an inline script that
does `import("@wordpress/boot").then(mod => mod.init(...))`. Because the
handle has no `src`, only the inline is printed, and it runs as a classic
script the moment the parser reaches it.
On fast CDN-fronted hosts (WordPress VIP, CloudFront, etc.) in Chrome,
`@wordpress/boot` is already `<link rel="modulepreload">`-ed, so the
dynamic import resolves and the module evaluates before the parser has
reached the classic deps it relies on (`wp-private-apis`, `wp-components`,
`wp-theme`). At its top-level `@wordpress/boot` reads
`window.wp.theme.privateApis`, which is still undefined at that point,
causing `unlock(undefined)` to throw "Cannot unlock an undefined object".
The mount element stays empty and `initSinglePage` / `init` never runs.
Wrap the dynamic import in `DOMContentLoaded`. The HTML spec guarantees
`DOMContentLoaded` fires only after every parser-blocking classic
`<script>` has executed, so all required globals are populated before
`@wordpress/boot` evaluates. A `document.readyState` guard preserves the
existing behavior when the inline is evaluated after DOM ready (e.g.
injected late).
Applied to all four auto-generated files that share the pattern:
* src/wp-includes/build/pages/options-connectors/page.php
* src/wp-includes/build/pages/options-connectors/page-wp-admin.php
* src/wp-includes/build/pages/font-library/page.php
* src/wp-includes/build/pages/font-library/page-wp-admin.php
Fixes #65103.
Made-with: Cursor1 parent 67094ee commit 484acd5
File tree
4 files changed
+48
-8
lines changed- src/wp-includes/build/pages
- font-library
- options-connectors
4 files changed
+48
-8
lines changedLines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
157 | 167 | | |
158 | 168 | | |
159 | 169 | | |
160 | | - | |
| 170 | + | |
161 | 171 | | |
162 | 172 | | |
163 | 173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
163 | 173 | | |
164 | 174 | | |
165 | 175 | | |
166 | 176 | | |
167 | | - | |
| 177 | + | |
168 | 178 | | |
169 | 179 | | |
170 | 180 | | |
| |||
Lines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
157 | 167 | | |
158 | 168 | | |
159 | 169 | | |
160 | | - | |
| 170 | + | |
161 | 171 | | |
162 | 172 | | |
163 | 173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
163 | 173 | | |
164 | 174 | | |
165 | 175 | | |
166 | 176 | | |
167 | | - | |
| 177 | + | |
168 | 178 | | |
169 | 179 | | |
170 | 180 | | |
| |||
0 commit comments