Load this when optimizing or writing request-path code. Two halves: server (every request) and browser (every frame).
- Only enqueue what the current page needs:
is_front_page(),is_singular(),is_page_template(),is_admin()— one enqueue function per context - Never load admin assets on the front end or vice versa
wp_enqueue_*only — no hardcoded<link>/<script>in templates- Strategy
deferfor module scripts; conditionalcomment-replyetc.
add_option( ..., false )(autoload: false) for anything large/rarely used — autoloaded options load on EVERY request- Transients for cached computed data — never options; never
update_optionper request - Object cache /
wp_cache_*for repeated lookups
pre_get_poststo modify the main query instead of duplicateWP_Queryno_found_rows => true,'fields' => 'ids'where applicable- Always
wp_reset_postdata()after custom query loops - Prefer API functions (in-memory cached) over raw
$wpdb - Lazy-load heavy data; paginate with
paged
- Read the Vite manifest once per request (static-cached)
- Preload critical fonts (woff2,
font-display: swap); async-load non-critical CSS with<noscript>fallback - Version assets for cache-busting
- Entry imports CSS + core JS only; Three.js / QR / heavy libs behind dynamic
import()chunks; vendor groups ≤ ~300KB; raisechunkSizeWarningLimitdeliberately - IntersectionObserver-based init for below-fold components
- One loop: Tempus; gate expensive work on
state.budget(ms left in frame) - Pause/unsubscribe loops when elements leave viewport (IntersectionObserver)
- Frame-skip on low-core machines:
navigator.hardwareConcurrency <= 4 - FPS-throttle non-critical callbacks (
{ fps: 30 })
- Animate only
transform/opacity(compositor); never layout properties - No
* { transition: all }; no forced reflows in loops (read-then-write batching) - Avoid
filter/bluron large layers; nowill-change: transformon ancestors ofposition: fixed - Lenis on native scroll (cheap, sticky-safe);
data-lenis-preventoverallowNestedScroll(per-DOM-check cost)
<img loading="lazy">,srcset/sizes; video lazy + preload metadatacontent-visibility: autofor long off-screen sections where safe
- Server: trace one request — what's enqueued (Query Monitor or inspect HTML), which
options autoload (
SELECT option_name FROM wp_options WHERE autoload='yes'), query count (save_queries), transients hit - Front-end:
vite buildoutput analysis (chunk sizes, dynamic chunks), animation loop count, DOM mutations per frame (devtools) - Report measured findings only — never fabricate Lighthouse/bundle numbers; flag what needs browser profiling
- web.dev — Core Web Vitals — the metrics (LCP, INP, CLS) these rules serve
- WordPress Core Performance team — core performance work and the Performance Lab plugin
- Query Monitor — request-path instrumentation (enqueues, options, queries)
- Vite — Build options — chunk splitting,
chunkSizeWarningLimit - Internal: front-end stack · theme architecture · plugin architecture