Editor V4: reduce request fan-out on load (per-image / per-document requests, usage scan, immediate retries on 10s timeout) #38551
Cel-lula
started this conversation in
Feature Request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Describe the Problem
On shared hosting, opening the V4 editor takes 50–90 s, and before our workaround it sometimes never finished (stuck on "Loading" with the "Can't edit?" notice).
Environment: WordPress 7.1.5, PHP 8.5 (FPM), shared hosting. Elementor 4.4.2 + Elementor Pro 4.4.2 (atomic editor: global classes, variables, components). WPML 5.4 (2 languages), Rank Math, Wordfence, Complianz, WP Fastest Cache.
Site size: ~385 published Elementor documents (279 posts, 68 pages, 38 templates), 121 global classes, ~90 global variables, 23 components.
A single REST/admin-ajax request takes ~1.7 s on this host (full WordPress bootstrap). We profiled the editor load with the Resource Timing and Long Animation Frames APIs:
Timeline of one editor load (front page):
post.php?action=elementor, ~5 MB)admin-ajaxget-attachment + default-styles + global-classes + collection-loop preview (several time out at 10 s)global-classes/post(2 per document) +components/overridable-props(most time out at 10 s)The same page opens in a few seconds on a local machine (0.1–0.3 s per request).
Specific behaviours that multiply the load:
GET /elementor/v1/global-classes/usagescans every published document on every editor load.Applied_Global_Classes_Usage::build_class_usages()iterates all documents throughiterate_elementor_documents()and analyzes each one. It takes 0.44 s locally and 9.7 s on the host when run alone, right at the editor's 10 s timeout.admin-ajax.php(get-attachment) request per image. The front page fires ~30, up to 14 at the same time, and each one bootstraps the whole of WordPress.global-classes/postrequests per document (context=previewandcontext=frontend) for the page, the header, the footer and each component: 14 parallel requests in our case.default-styles,global-classes?context=preview|frontendandglobalsare requested more than once (e.g.globalstwice at 24.5 s and 24.6 s;default-styles/global-classesat ~9 s and again at ~32 s).Propose a Solution
Keep the number of requests the editor makes on load small and fixed, independent of the number of images or embedded documents:
get-attachmentrequest per image.global-classes/post: one request that accepts several post IDs and returns both contexts (previewandfrontend).default-styles,global-classesandglobalswithin a single editor load.Additional Context
Workarounds we are using (mu-plugins), which confirm the impact:
global-classes/usage: the response is stored in an option and served from there. When content or classes change, the last result is still served while it is rebuilt in the background via WP-Cron. This alone removed the "stuck on Loading" state: the request went from 9.7 s to ~1.7 s, the host's minimum.get-attachmentwhen the referer is the editor), plugins that play no part in those responses (SEO, cookie consent, backup, page cache) are not loaded. Responses are byte-identical, and editor load time went from 78–88 s to 49–53 s.Even with both workarounds, the editor still makes ~57 PHP requests on load, and 6–8 of them still hit the 10 s timeout and are retried. Batching (points 2 and 3) and backoff (point 4) would make the V4 editor usable on modest hosting, where most small business sites live.
Happy to share the mu-plugins, or to run more measurements if useful.
Agreement
All reactions