Performance: 20x fewer field-lookup queries, screen-gated heavy assets, 4MB lighter zip#451
Conversation
… screens PHP runtime (measured in wp-env, cache-less host): - Prime sibling field definitions when a field key resolves: get_field() across a 50-field template drops from 101 SQL queries / ~17ms to 5 queries / ~2.8ms. Opt-out via acf/prime_field_group_fields filter; per-field load_field filters unchanged. - Decode each local JSON file once per request instead of 4x: 44ms -> 16ms at 200 files. - Per-request cache for acf_get_option_meta() LIKE queries, invalidated via core added/updated/deleted_option hooks. - acf_decode_taxonomy_term(): raw term_taxonomy SQL -> get_term(). - Early-bail block save parsing when no block types are registered. - Enqueue the escaped-html notice script only when the notice renders. - Memoize the WP version check in acf_is_using_datastore(). Assets: - Load scf-bindings only in block editor contexts; it previously pulled the full wp-editor dependency stack onto classic admin pages and public front-end acf_form() pages. - Gate command-palette scripts on wp-commands being enqueued (stops React + wp-components loading on every classic admin page on WP <=6.8). - Drop wp-polyfill dependency from all bundles (webpack injectPolyfill). - Fix pro CSS min suffix: production shipped unminified acf-pro-input.css. - Gate admin-only acf-pro-ui-options-page script with is_admin(). - Fix acf-dark stylesheet 404 (wrong path since the build move). - Exclude assets/src and source maps from the release zip (-4.2MB). Verified: 2788 PHPUnit / 946 Jest / 253 E2E tests green, PHPStan clean, zero tests modified. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Superseded by #466. This PR was auto-closed when its base branch (the test battery) merged into |
This PR implements the highest-impact, lowest-risk items from a measured performance audit of the plugin (PHP runtime profiled in wp-env with query/timing instrumentation; asset graph audited bundle-by-bundle). All changes are behavior-identical: the full battery (2788 PHPUnit / 946 Jest / 253 E2E / PHPStan) passes without modifying a single test.
PHP runtime
includes/acf-field-functions.php)get_field()over a 50-field template: 101 → 5 SQL queries, ~17ms → ~2.8ms (cache-less hosts)includes/local-json.php)acf_get_option_meta()with invalidation via core option hooks (includes/acf-meta-functions.php)LIKEquery then 0 on repeatacf_decode_taxonomy_term(): rawterm_taxonomySQL →get_term()(term cache)includes/blocks.php)includes/admin/admin.php)acf_is_using_datastore()(includes/datastore.php)The priming behavior has an escape hatch:
acf/prime_field_group_fieldsfilter (defaulttrue) for plugins that filter per-key field queries (e.g. multilingual plugins). Per-fieldacf/load_fieldfilters still run exactly as before — only the raw key→post lookup is primed.Assets / enqueue
scf-bindingsmoved toenqueue_block_editor_assets(includes/assets.php)acf_form()pages where the bindings UI cannot functionwp_script_is( 'wp-commands', 'enqueued' )(includes/admin/admin-commands.php)injectPolyfillfrom webpackwp-polyfilldependency (~30 KB gz) from every script handle, including front-end formsincludes/assets.php)acf-pro-input.min.css(32.6 KB) instead of the unminified 47.2 KB file on every edit screen and front-end formacf-pro-ui-options-page(admin-only feature) withis_admin()acf-darkstylesheet path (includes/third-party.php)assets/css/never existed)bin/create-release-zip.sh): excludeassets/src/and source mapsSCF_DEVELOPMENT_MODEloads them); select2 v3 kept (still reachable via theselect2_versionsetting)Deliberately not included (higher risk, future candidates)
Splitting
acf-global.css(loads 21 KB gz on every admin page — needs visual QA), lazy field-type loading,deferonacf/acf-input(third-party scripts assumeacfat parse time), conditional select2 loading, and CSS recompilation from source partials.Verification
composer test:php: OK (2788 tests, 6371 assertions) — zero tests modifiedcomposer test:phpstan: cleannpm run test:unit: 946/946Closes
Use of AI Tools
This PR was authored by Claude Code (Claude Fable 5) under human direction. The audit, the selection of which optimizations to implement vs defer, and all changes were validated by benchmarks and the full test battery; build artifacts are generated by the standard
npm run build.