Skip to content

Fix: improve performance by loading snippets only on manage screen#389

Merged
rami-elementor merged 1 commit into
core-betafrom
performance-optimization-non-manage-subpages
May 12, 2026
Merged

Fix: improve performance by loading snippets only on manage screen#389
rami-elementor merged 1 commit into
core-betafrom
performance-optimization-non-manage-subpages

Conversation

@rami-elementor
Copy link
Copy Markdown
Contributor

@rami-elementor rami-elementor commented May 7, 2026

The change in Manage_Menu.php makes snippetsList conditional.

Previously, every Manage Code Snippets page request localized the full result of get_snippets() into window.CODE_SNIPPETS_MANAGE, even when displaying the Community Cloud page or the Blueprints page (in Pro).

Now, it builds the common localized settings first, and only adds the full snippets payload when it's not a sub-page. As a result, it no longer loads the full result of snippets on subpages.

How does it affect different pages:

  • /wp-admin/admin.php?page=snippets (no change)
  • /wp-admin/admin.php?page=snippets&subpage=blueprints (optimized)
  • /wp-admin/admin.php?page=snippets&subpage=cloud-community (optimized)

Performance benefits:

  • Avoids get_snippets() on the Community Cloud subpage.
  • Avoids a full SELECT * from the snippets table when the snippets cache is cold.
  • Avoids hydrating every DB row into a Snippet object.
  • Avoids per-snippet locked-status lookups via is_snippet_locked().
  • Avoids mapping every Snippet through get_fields().
  • Avoids printing the full snippets list into inline page JavaScript, which reduces HTML size, memory use, and parse/transfer cost.

@rami-elementor rami-elementor requested a review from a team May 7, 2026 15:44
@rami-elementor rami-elementor added the run-tests Trigger automated tests label May 7, 2026
@rami-elementor rami-elementor merged commit adfb293 into core-beta May 12, 2026
23 checks passed
@rami-elementor rami-elementor deleted the performance-optimization-non-manage-subpages branch May 12, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-tests Trigger automated tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant