Skip to content

Fix: improve performance by not loading REST controllers on frontend#387

Merged
rami-elementor merged 1 commit intocore-betafrom
performance-optimization-for-rest-api
May 7, 2026
Merged

Fix: improve performance by not loading REST controllers on frontend#387
rami-elementor merged 1 commit intocore-betafrom
performance-optimization-for-rest-api

Conversation

@rami-elementor
Copy link
Copy Markdown
Contributor

Code snippets registers 5 REST controllers on every request (frontend included).

Why it matters? Because it registers rest_api_init hooks on frontend requests where they will never fire (REST requests go through a separate path).

These five REST controller instances are created on every request, each adding an add_action('rest_api_init', ...) hook. On pure frontend page loads, rest_api_init never fires, so the routes are never registered — but the constructor + hook registration still runs.

The PR defers REST controller instantiation — wrap the 5 REST controllers in a single rest_api_init callback that creates them lazily. Saves ~5 object constructions + hook registrations on frontend.

@rami-elementor rami-elementor requested a review from a team May 6, 2026 06:32
@rami-elementor rami-elementor merged commit 664ae20 into core-beta May 7, 2026
8 checks passed
@rami-elementor rami-elementor deleted the performance-optimization-for-rest-api branch May 7, 2026 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants