[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7FB8RRE189A47D1RTEWGRJS":3,"skill-same:01M7FB8RRE189A47D1RTEWGRJS":78},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":42,"commitSha":43,"skillDirectory":44,"forksCount":45,"repositoryHtmlUrl":46,"repositoryHomepageUrl":6,"ownerHtmlUrl":47,"ownerBlogUrl":6,"ownerDescription":48,"updatedAt":49,"install":50,"resources":63},"01M7FB8RRE189A47D1RTEWGRJS","performance",null,"Use when a page or interaction is slow for one user and the fix starts from a measurement — a failing Core Web Vital (LCP, INP, CLS), a heavy JS bundle, wasted re-renders, an over-broad client boundary: profile, attribute the cost to one phase, fix it, re-measure. NOT surviving concurrent load (that is `scaling`), NOT the slow query (that is `postgresdb`).","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Fperformance\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: performance\ndescription: \"Use when a page or interaction is slow for one user and the fix starts from a measurement — a failing Core Web Vital (LCP, INP, CLS), a heavy JS bundle, wasted re-renders, an over-broad client boundary: profile, attribute the cost to one phase, fix it, re-measure. NOT surviving concurrent load (that is `scaling`), NOT the slow query (that is `postgresdb`).\"\ntags: [performance, core-web-vitals, lcp, inp, cls, bundle-size, profiling, react, web-vitals]\nrecommends: [scaling, postgresdb, redis, nextjs, react, observability, monitoring]\nprofiles: []\norigin: risco\n---\n\n# Performance: make one thing fast\n\nPerformance makes a single request, page, or interaction faster for one user. Scaling makes many requests survive at the same time. Different problem, different toolbox — if the system is fine for you and only bends under concurrent load, that is `..\u002Fscaling\u002FSKILL.md`, not this.\n\nThe whole job in one line: **measure with a profiler → attribute the cost to one specific phase → apply the one fix that moves that phase → re-measure against a number.** Repeat until you clear the threshold, then stop.\n\n**Prime directive: no fix without a profile first.** A waterfall, a flame chart, a bundle treemap, or a field CWV number comes before you touch code. The fix you guess is almost never the fix the measurement points at, and a \"fast\" change that moves a phase nobody was waiting on is wasted work that you then have to maintain.\n\nCross-reference, don't duplicate: the last column of the table below names where each deep fix lives. The one case it has no row for — you decided *what* to cache to cut a phase and now need that cache race-free — is `..\u002Fredis\u002FSKILL.md`.\n\n## Decision table — symptom to first move\n\n| Symptom | Metric \u002F phase | First probe | First lever | Deep fix lives in |\n|---|---|---|---|---|\n| Slow load, hero appears late | LCP | Lighthouse + DevTools trace | attribute to a subpart, then fix that one | this skill \u002F `..\u002Fpostgresdb\u002FSKILL.md` if TTFB |\n| Janky scroll, laggy typing\u002Fclick | INP | DevTools Performance trace (long-task bars) | break the >50 ms task, yield | this skill |\n| Layout jumps as it loads | CLS | Lighthouse layout-shift trace | reserve space (dimensions \u002F aspect-ratio) | this skill |\n| \"First Load JS is huge\" | bundle bytes | `@next\u002Fbundle-analyzer` \u002F `source-map-explorer` | kill\u002Freplace the heavy dep, then dynamic import | this skill |\n| Component re-renders constantly | render time | React DevTools Profiler (\"why did this render\") | fix the unstable ref \u002F boundary | `..\u002Freact\u002FSKILL.md` for the pattern |\n| `'use client'` drags server work down | First Load JS | bundle analyzer server\u002Fclient trace | push the boundary to a leaf | `..\u002Fnextjs\u002FSKILL.md` |\n| Slow **only** under concurrent load | throughput, not latency | load test | — not this skill — | `..\u002Fscaling\u002FSKILL.md` |\n| TTFB dominated by one query | server time | query plan \u002F `EXPLAIN` | — not this skill — | `..\u002Fpostgresdb\u002FSKILL.md` |\n\n## Step 0 — measure first: field vs lab\n\nYou have two kinds of measurement and they answer different questions. Use both, in this order.\n\n- **Field data (CrUX, RUM via the `web-vitals` library) at the 75th percentile** tells you *what real users actually feel*. A metric passes when ≥75% of page views hit \"good\". This is the only number that matters for \"is it actually a problem\".\n- **Lab data (Lighthouse, the Chrome DevTools Performance trace)** tells you *why* — it reproduces one load under controlled conditions so you can read the waterfall and flame chart.\n\n**Rule: never optimize a lab number that no real user ever hits, and never report the mean — report the 75th percentile.** A lab Lighthouse run on a throttled cold cache can show an LCP your field p75 never sees; chasing it burns time on a phantom. Conversely a field INP failure with a clean lab run means you have not reproduced the slow interaction yet — go find it.\n\nThe output of Step 0 is **one sentence naming the bottleneck**: \"LCP is 3.8 s and 2.1 s of it is resource load delay because the hero image is lazy-loaded.\" Do not proceed without that sentence. Tool runbooks (Lighthouse CI flags, reading a flame chart, the Profiler workflow, wiring `web-vitals` for RUM) live in `references\u002Fprofiling-playbook.md`.\n\n**Measurement honesty:** static source can identify a *plausible* bottleneck, never a measured LCP\u002FINP\u002FCLS, latency win or byte saving. If runtime\u002Ffield data is unavailable, label the finding `POTENTIAL`, name the exact trace\u002Fbenchmark needed, and make no numeric improvement claim. Do not turn code inspection into fictional telemetry.\n\nKeep one experiment card per change:\n\n```text\nmetric + conditions | baseline distribution | one hypothesis\u002Fchange | after distribution | keep\u002Frevert | next\n```\n\nUse the same device, data volume, cache state, build mode and sampling method before and after. Repeat enough runs to see ordinary variance; a one-off result inside that noise is neutral. Keep a change only when it moves the target beyond the noise without violating another budget. Revert a neutral or worse experiment with a targeted edit and preserve the card — failed attempts prevent the next person from paying for the same guess.\n\n## CWV \"good\" thresholds (field p75)\n\n| Metric | Good | Needs improvement | Poor |\n|---|---|---|---|\n| LCP | ≤ 2.5 s | 2.5–4.0 s | > 4.0 s |\n| INP | ≤ 200 ms | 200–500 ms | > 500 ms |\n| CLS | ≤ 0.1 | 0.1–0.25 | > 0.25 |\n\nINP replaced FID as a Core Web Vital in March 2024 and is still a CWV — it measures the full interaction-to-next-paint, so a fast event handler with a slow paint still fails. As of 2025, ~62% of mobile pages hit good LCP (up from 44% in 2022), and LCP remains the hardest CWV to pass and the most common overall bottleneck — so start there when the symptom is \"slow load\".\n\n## LCP — attribute to a subpart before fixing\n\nLCP is not one thing. It decomposes into four sequential phases, and **each phase has a different fix**. Attribute first, then fix only the dominant phase.\n\n| Subpart | What it is | The fix that moves it |\n|---|---|---|\n| TTFB | server + network to first byte | server work — punt to `..\u002Fpostgresdb\u002FSKILL.md` (slow query) or `..\u002Fscaling\u002FSKILL.md` (under load); cache the response |\n| Resource load delay | gap between TTFB and the LCP resource *starting* to load | discoverability — `\u003Clink rel=\"preload\">`, `fetchpriority=\"high\"`, never lazy-load the hero |\n| Resource load duration | time to actually download the LCP resource | smaller\u002Fnext-gen image, CDN, right dimensions, `priority` on `next\u002Fimage` |\n| Element render delay | resource downloaded but not yet painted | unblock the main thread \u002F render-blocking CSS\u002FJS, font readiness |\n\nA text-node LCP rendered in a system font has zero load delay and zero load duration — its budget is all TTFB and render delay, so don't go hunting for an image to preload.\n\nThe single most common LCP mistake is lazy-loading the largest element. Make it eager and high priority:\n\n```html\n\u003C!-- Bad: the hero is the LCP element and you just deferred it -->\n\u003Cimg src=\"\u002Fhero.webp\" loading=\"lazy\" alt=\"Product\" \u002F>\n\n\u003C!-- Good: eager + high priority + reserved dimensions (also kills CLS) -->\n\u003Clink rel=\"preload\" as=\"image\" href=\"\u002Fhero.webp\" fetchpriority=\"high\" \u002F>\n\u003Cimg src=\"\u002Fhero.webp\" fetchpriority=\"high\" width=\"1200\" height=\"630\" alt=\"Product\" \u002F>\n```\n\n```tsx\n\u002F\u002F Next.js: `priority` sets fetchpriority=high and disables lazy-loading for the LCP image\nimport Image from \"next\u002Fimage\";\n\u003CImage src=\"\u002Fhero.webp\" width={1200} height={630} priority alt=\"Product\" \u002F>;\n```\n\n## INP — kill the long task\n\nINP is dominated by **long tasks**: any main-thread task over **50 ms** blocks every interaction for its full duration. The fix is to break long work into chunks under 50 ms and yield to the main thread between them so a queued click or keypress can run.\n\n```ts\n\u002F\u002F Bad: one 400ms loop blocks every click\u002Fkeypress while it runs\nfunction processAll(items: Item[]) {\n  for (const item of items) heavyWork(item); \u002F\u002F one long task\n}\n\n\u002F\u002F Good: chunk + yield. scheduler.yield() resumes at the FRONT of the queue,\n\u002F\u002F so your continuation isn't starved behind newly-queued work.\nasync function processAll(items: Item[]) {\n  for (let i = 0; i \u003C items.length; i++) {\n    heavyWork(items[i]);\n    if (i % 50 === 0 && \"scheduler\" in globalThis) {\n      await (globalThis as any).scheduler.yield();\n    }\n  }\n}\n```\n\nOther INP levers, in order of payoff:\n\n- **Move third-party JS off the main thread** (analytics, chat widgets, tag managers) — defer, load on interaction, or sandbox in a worker. Third-party scripts are the usual hidden long-task source.\n- **Defer non-urgent handler work.** Do the visible state update now; push the expensive recompute behind `requestIdleCallback`, a debounce, or `startTransition`.\n- **Measure the actual interaction** — the field INP failure names *which* interaction; reproduce it in a DevTools trace and read the long-task bar, don't guess.\n\n## CLS — reserve the space\n\nCLS comes from space that was not reserved before content arrived: images\u002Fvideo\u002Fads\u002Fembeds without dimensions, content injected above existing content, and font swaps (FOUT). Fix by reserving the box up front.\n\n```html\n\u003C!-- Bad: no dimensions, image reflows everything below it on load -->\n\u003Cimg src=\"\u002Fcard.webp\" alt=\"\" \u002F>\n\n\u003C!-- Good: explicit box, zero shift -->\n\u003Cimg src=\"\u002Fcard.webp\" width=\"400\" height=\"300\" alt=\"\" \u002F>\n```\n\n```css\n\u002F* Reserve space for ratio-based media and swap fonts without reflow *\u002F\n.media { aspect-ratio: 16 \u002F 9; }                 \u002F* box exists before load *\u002F\n@font-face { font-family: Inter; font-display: optional; size-adjust: 100%; }\n```\n\nRules: give every image\u002Fembed explicit `width`\u002F`height` or an `aspect-ratio`; render skeleton boxes the size of the real content; never insert banners\u002Fnotices above content the user is already reading (push them below or overlay); use `font-display: optional` (or `swap` + `size-adjust`) so a font swap doesn't reflow text.\n\n## Bundle size — analyze before you cut\n\nNever guess what's heavy. Generate a treemap, read it, then cut the biggest box.\n\n```bash\n# Next.js: interactive treemap with server\u002Fclient import tracing (Turbopack module graph)\nANALYZE=true npm run build      # with @next\u002Fbundle-analyzer wired in next.config\n\n# Any webpack\u002FVite build: attribute bytes back to source via source maps\nnpx source-map-explorer 'dist\u002F**\u002F*.js'\n```\n\nLevers in order of payoff:\n\n1. **Kill or replace the heavy dependency.** The treemap usually shows one or two boxes dwarfing everything (a date library, an icon set, a charting lib). Replace with a lighter one or a few lines of your own.\n2. **Dynamic `import()` for non-critical UI.** Modals, editors, charts, anything below the fold or behind an interaction loads on demand instead of in First Load JS.\n3. **Fix tree-shaking — stop importing the whole library for one function.** `import _ from \"lodash\"` pulls the entire library; import the one function (or use the native equivalent).\n\n```tsx\n\u002F\u002F Bad: whole library in the initial bundle for one helper\nimport _ from \"lodash\";\nconst fn = _.debounce(save, 300);\n\n\u002F\u002F Good: named import (tree-shakeable) — or just write the 6-line debounce\nimport debounce from \"lodash-es\u002Fdebounce\";\nconst fn = debounce(save, 300);\n```\n\n```tsx\n\u002F\u002F Bad: heavy editor in First Load JS even though it's behind a button\nimport { RichEditor } from \"@org\u002Frich-editor\";\n\n\u002F\u002F Good: split it out, load on demand\nimport dynamic from \"next\u002Fdynamic\";\nconst RichEditor = dynamic(() => import(\"@org\u002Frich-editor\"), { ssr: false });\n```\n\n## Render cost — React 19, the compiler, and the boundary\n\n**React 19 with the React Compiler auto-memoizes**, so blanket defensive `useMemo`\u002F`useCallback`\u002F`memo` is now an anti-pattern, not a best practice — it adds noise and the compiler already handles the common cases. Manual memo is the exception, and you justify it with a profile.\n\n- Profile with the **React DevTools Profiler**: record an interaction, find the component that re-rendered, read \"why did this render\" and its render time.\n- **The 16 ms rule:** one frame at 60 fps is ~16 ms. If a manual memo saves less than that, skip it — you can't see it and you're paying for the cache.\n- The compiler **cannot** fix a new object\u002Farray\u002Ffunction reference created in render and passed as a prop — that's a fresh identity every time. Hoist it or derive it stably; that's the real fix, not wrapping the consumer in `memo`.\n\n**RSC boundary discipline.** React Server Components ship zero JS for non-interactive trees; teams report 50–70% First-Load-JS cuts from full RSC adoption. The `'use client'` directive is a *boundary*: everything imported below it becomes client code. So push interactivity into the smallest leaf component and keep data fetching and layout on the server.\n\n```tsx\n\u002F\u002F Bad: 'use client' at the top of the route — the whole tree ships to the browser\n\"use client\";\nexport default function ProductPage({ data }) {\n  \u002F* layout, data display, and one tiny button all client-side *\u002F\n}\n\n\u002F\u002F Good: server component holds data\u002Flayout; only the interactive leaf is a client component\nexport default function ProductPage({ data }) {       \u002F\u002F server: zero JS\n  return (\n    \u003Carticle>\n      \u003CProductDetails data={data} \u002F>                  {\u002F* server *\u002F}\n      \u003CAddToCartButton id={data.id} \u002F>                {\u002F* the only 'use client' file *\u002F}\n    \u003C\u002Farticle>\n  );\n}\n```\n\nUse **streaming SSR with `\u003CSuspense>`** to flush the static shell immediately and stream slow subtrees in parallel — multiple independent boundaries stream concurrently, cutting time-to-first-paint when one section is data-bound. The canonical App-Router data and component patterns are `..\u002Fnextjs\u002FSKILL.md` and `..\u002Freact\u002FSKILL.md`; bring the perf loop here, take the idioms there.\n\n## Anti-patterns\n\n| Anti-pattern | Why it's wrong | Do instead |\n|---|---|---|\n| Optimizing on a hunch, no profile | you fix a phase nobody waits on | measure → attribute → fix the dominant phase |\n| Chasing a lab score no real user hits | lab cold-cache LCP ≠ field p75 | optimize the field 75th-percentile number |\n| Reporting the mean, not p75 | the average hides the tail users feel | always read\u002Freport the 75th percentile |\n| Blanket `useMemo`\u002F`useCallback` in React 19 | the compiler already memoizes; you add noise | memo only what the Profiler proves >16 ms |\n| Lazy-loading the LCP \u002F hero image | you defer the very element LCP measures | `priority` \u002F `fetchpriority=high`, eager |\n| `import _ from \"lodash\"` for one function | the whole library lands in First Load JS | named import or a few lines of your own |\n| `'use client'` at the top of the tree | the entire subtree ships to the browser | push the boundary to the interactive leaf |\n| Images\u002Fembeds with no reserved space | content reflows on load → CLS | explicit width\u002Fheight or `aspect-ratio` |\n| Micro-optimizing a non-bottleneck phase | effort moves a number off the critical path | fix only the phase the trace points at |\n| \"Done\" without re-measuring | the fix may not have moved the metric | re-measure against the threshold, then stop |\n| Reporting source-only review as a measured win | no trace\u002Ffield\u002Fbenchmark ran, so the number is invented | label POTENTIAL and name the measurement |\n| Changing three levers in one experiment | you cannot attribute the result or reuse the learning | one hypothesis\u002Fchange per card, then re-measure |\n| Keeping a neutral optimization | complexity rose but the target did not beat normal variance | targeted revert; retain the failed-experiment record |\n\n## Stop rule\n\nYou are done when the **field 75th percentile clears the \"good\" threshold** (LCP ≤ 2.5 s, INP ≤ 200 ms, CLS ≤ 0.1) and your bundle is under its budget — re-measure to confirm, then stop. Going from \"good\" to \"slightly better good\" is gold-plating: it costs maintenance and moves a number no user notices. Commit the threshold as a budget so it can't silently regress (`scripts\u002Fverify.sh` lints that budget; see `references\u002Fprofiling-playbook.md` for the field-RUM wiring that keeps the p75 honest in production).\n","# Performance: make one thing fast\n\nPerformance makes a single request, page, or interaction faster for one user. Scaling makes many requests survive at the same time. Different problem, different toolbox — if the system is fine for you and only bends under concurrent load, that is `..\u002Fscaling\u002FSKILL.md`, not this.\n\nThe whole job in one line: **measure with a profiler → attribute the cost to one specific phase → apply the one fix that moves that phase → re-measure against a number.** Repeat until you clear the threshold, then stop.\n\n**Prime directive: no fix without a profile first.** A waterfall, a flame chart, a bundle treemap, or a field CWV number comes before you touch code. The fix you guess is almost never the fix the measurement points at, and a \"fast\" change that moves a phase nobody was waiting on is wasted work that you then have to maintain.\n\nCross-reference, don't duplicate: the last column of the table below names where each deep fix lives. The one case it has no row for — you decided *what* to cache to cut a phase and now need that cache race-free — is `..\u002Fredis\u002FSKILL.md`.\n\n## Decision table — symptom to first move\n\n| Symptom | Metric \u002F phase | First probe | First lever | Deep fix lives in |\n|---|---|---|---|---|\n| Slow load, hero appears late | LCP | Lighthouse + DevTools trace | attribute to a subpart, then fix that one | this skill \u002F `..\u002Fpostgresdb\u002FSKILL.md` if TTFB |\n| Janky scroll, laggy typing\u002Fclick | INP | DevTools Performance trace (long-task bars) | break the >50 ms task, yield | this skill |\n| Layout jumps as it loads | CLS | Lighthouse layout-shift trace | reserve space (dimensions \u002F aspect-ratio) | this skill |\n| \"First Load JS is huge\" | bundle bytes | `@next\u002Fbundle-analyzer` \u002F `source-map-explorer` | kill\u002Freplace the heavy dep, then dynamic import | this skill |\n| Component re-renders constantly | render time | React DevTools Profiler (\"why did this render\") | fix the unstable ref \u002F boundary | `..\u002Freact\u002FSKILL.md` for the pattern |\n| `'use client'` drags server work down | First Load JS | bundle analyzer server\u002Fclient trace | push the boundary to a leaf | `..\u002Fnextjs\u002FSKILL.md` |\n| Slow **only** under concurrent load | throughput, not latency | load test | — not this skill — | `..\u002Fscaling\u002FSKILL.md` |\n| TTFB dominated by one query | server time | query plan \u002F `EXPLAIN` | — not this skill — | `..\u002Fpostgresdb\u002FSKILL.md` |\n\n## Step 0 — measure first: field vs lab\n\nYou have two kinds of measurement and they answer different questions. Use both, in this order.\n\n- **Field data (CrUX, RUM via the `web-vitals` library) at the 75th percentile** tells you *what real users actually feel*. A metric passes when ≥75% of page views hit \"good\". This is the only number that matters for \"is it actually a problem\".\n- **Lab data (Lighthouse, the Chrome DevTools Performance trace)** tells you *why* — it reproduces one load under controlled conditions so you can read the waterfall and flame chart.\n\n**Rule: never optimize a lab number that no real user ever hits, and never report the mean — report the 75th percentile.** A lab Lighthouse run on a throttled cold cache can show an LCP your field p75 never sees; chasing it burns time on a phantom. Conversely a field INP failure with a clean lab run means you have not reproduced the slow interaction yet — go find it.\n\nThe output of Step 0 is **one sentence naming the bottleneck**: \"LCP is 3.8 s and 2.1 s of it is resource load delay because the hero image is lazy-loaded.\" Do not proceed without that sentence. Tool runbooks (Lighthouse CI flags, reading a flame chart, the Profiler workflow, wiring `web-vitals` for RUM) live in `references\u002Fprofiling-playbook.md`.\n\n**Measurement honesty:** static source can identify a *plausible* bottleneck, never a measured LCP\u002FINP\u002FCLS, latency win or byte saving. If runtime\u002Ffield data is unavailable, label the finding `POTENTIAL`, name the exact trace\u002Fbenchmark needed, and make no numeric improvement claim. Do not turn code inspection into fictional telemetry.\n\nKeep one experiment card per change:\n\n```text\nmetric + conditions | baseline distribution | one hypothesis\u002Fchange | after distribution | keep\u002Frevert | next\n```\n\nUse the same device, data volume, cache state, build mode and sampling method before and after. Repeat enough runs to see ordinary variance; a one-off result inside that noise is neutral. Keep a change only when it moves the target beyond the noise without violating another budget. Revert a neutral or worse experiment with a targeted edit and preserve the card — failed attempts prevent the next person from paying for the same guess.\n\n## CWV \"good\" thresholds (field p75)\n\n| Metric | Good | Needs improvement | Poor |\n|---|---|---|---|\n| LCP | ≤ 2.5 s | 2.5–4.0 s | > 4.0 s |\n| INP | ≤ 200 ms | 200–500 ms | > 500 ms |\n| CLS | ≤ 0.1 | 0.1–0.25 | > 0.25 |\n\nINP replaced FID as a Core Web Vital in March 2024 and is still a CWV — it measures the full interaction-to-next-paint, so a fast event handler with a slow paint still fails. As of 2025, ~62% of mobile pages hit good LCP (up from 44% in 2022), and LCP remains the hardest CWV to pass and the most common overall bottleneck — so start there when the symptom is \"slow load\".\n\n## LCP — attribute to a subpart before fixing\n\nLCP is not one thing. It decomposes into four sequential phases, and **each phase has a different fix**. Attribute first, then fix only the dominant phase.\n\n| Subpart | What it is | The fix that moves it |\n|---|---|---|\n| TTFB | server + network to first byte | server work — punt to `..\u002Fpostgresdb\u002FSKILL.md` (slow query) or `..\u002Fscaling\u002FSKILL.md` (under load); cache the response |\n| Resource load delay | gap between TTFB and the LCP resource *starting* to load | discoverability — `\u003Clink rel=\"preload\">`, `fetchpriority=\"high\"`, never lazy-load the hero |\n| Resource load duration | time to actually download the LCP resource | smaller\u002Fnext-gen image, CDN, right dimensions, `priority` on `next\u002Fimage` |\n| Element render delay | resource downloaded but not yet painted | unblock the main thread \u002F render-blocking CSS\u002FJS, font readiness |\n\nA text-node LCP rendered in a system font has zero load delay and zero load duration — its budget is all TTFB and render delay, so don't go hunting for an image to preload.\n\nThe single most common LCP mistake is lazy-loading the largest element. Make it eager and high priority:\n\n```html\n\u003C!-- Bad: the hero is the LCP element and you just deferred it -->\n\u003Cimg src=\"\u002Fhero.webp\" loading=\"lazy\" alt=\"Product\" \u002F>\n\n\u003C!-- Good: eager + high priority + reserved dimensions (also kills CLS) -->\n\u003Clink rel=\"preload\" as=\"image\" href=\"\u002Fhero.webp\" fetchpriority=\"high\" \u002F>\n\u003Cimg src=\"\u002Fhero.webp\" fetchpriority=\"high\" width=\"1200\" height=\"630\" alt=\"Product\" \u002F>\n```\n\n```tsx\n\u002F\u002F Next.js: `priority` sets fetchpriority=high and disables lazy-loading for the LCP image\nimport Image from \"next\u002Fimage\";\n\u003CImage src=\"\u002Fhero.webp\" width={1200} height={630} priority alt=\"Product\" \u002F>;\n```\n\n## INP — kill the long task\n\nINP is dominated by **long tasks**: any main-thread task over **50 ms** blocks every interaction for its full duration. The fix is to break long work into chunks under 50 ms and yield to the main thread between them so a queued click or keypress can run.\n\n```ts\n\u002F\u002F Bad: one 400ms loop blocks every click\u002Fkeypress while it runs\nfunction processAll(items: Item[]) {\n  for (const item of items) heavyWork(item); \u002F\u002F one long task\n}\n\n\u002F\u002F Good: chunk + yield. scheduler.yield() resumes at the FRONT of the queue,\n\u002F\u002F so your continuation isn't starved behind newly-queued work.\nasync function processAll(items: Item[]) {\n  for (let i = 0; i \u003C items.length; i++) {\n    heavyWork(items[i]);\n    if (i % 50 === 0 && \"scheduler\" in globalThis) {\n      await (globalThis as any).scheduler.yield();\n    }\n  }\n}\n```\n\nOther INP levers, in order of payoff:\n\n- **Move third-party JS off the main thread** (analytics, chat widgets, tag managers) — defer, load on interaction, or sandbox in a worker. Third-party scripts are the usual hidden long-task source.\n- **Defer non-urgent handler work.** Do the visible state update now; push the expensive recompute behind `requestIdleCallback`, a debounce, or `startTransition`.\n- **Measure the actual interaction** — the field INP failure names *which* interaction; reproduce it in a DevTools trace and read the long-task bar, don't guess.\n\n## CLS — reserve the space\n\nCLS comes from space that was not reserved before content arrived: images\u002Fvideo\u002Fads\u002Fembeds without dimensions, content injected above existing content, and font swaps (FOUT). Fix by reserving the box up front.\n\n```html\n\u003C!-- Bad: no dimensions, image reflows everything below it on load -->\n\u003Cimg src=\"\u002Fcard.webp\" alt=\"\" \u002F>\n\n\u003C!-- Good: explicit box, zero shift -->\n\u003Cimg src=\"\u002Fcard.webp\" width=\"400\" height=\"300\" alt=\"\" \u002F>\n```\n\n```css\n\u002F* Reserve space for ratio-based media and swap fonts without reflow *\u002F\n.media { aspect-ratio: 16 \u002F 9; }                 \u002F* box exists before load *\u002F\n@font-face { font-family: Inter; font-display: optional; size-adjust: 100%; }\n```\n\nRules: give every image\u002Fembed explicit `width`\u002F`height` or an `aspect-ratio`; render skeleton boxes the size of the real content; never insert banners\u002Fnotices above content the user is already reading (push them below or overlay); use `font-display: optional` (or `swap` + `size-adjust`) so a font swap doesn't reflow text.\n\n## Bundle size — analyze before you cut\n\nNever guess what's heavy. Generate a treemap, read it, then cut the biggest box.\n\n```bash\n# Next.js: interactive treemap with server\u002Fclient import tracing (Turbopack module graph)\nANALYZE=true npm run build      # with @next\u002Fbundle-analyzer wired in next.config\n\n# Any webpack\u002FVite build: attribute bytes back to source via source maps\nnpx source-map-explorer 'dist\u002F**\u002F*.js'\n```\n\nLevers in order of payoff:\n\n1. **Kill or replace the heavy dependency.** The treemap usually shows one or two boxes dwarfing everything (a date library, an icon set, a charting lib). Replace with a lighter one or a few lines of your own.\n2. **Dynamic `import()` for non-critical UI.** Modals, editors, charts, anything below the fold or behind an interaction loads on demand instead of in First Load JS.\n3. **Fix tree-shaking — stop importing the whole library for one function.** `import _ from \"lodash\"` pulls the entire library; import the one function (or use the native equivalent).\n\n```tsx\n\u002F\u002F Bad: whole library in the initial bundle for one helper\nimport _ from \"lodash\";\nconst fn = _.debounce(save, 300);\n\n\u002F\u002F Good: named import (tree-shakeable) — or just write the 6-line debounce\nimport debounce from \"lodash-es\u002Fdebounce\";\nconst fn = debounce(save, 300);\n```\n\n```tsx\n\u002F\u002F Bad: heavy editor in First Load JS even though it's behind a button\nimport { RichEditor } from \"@org\u002Frich-editor\";\n\n\u002F\u002F Good: split it out, load on demand\nimport dynamic from \"next\u002Fdynamic\";\nconst RichEditor = dynamic(() => import(\"@org\u002Frich-editor\"), { ssr: false });\n```\n\n## Render cost — React 19, the compiler, and the boundary\n\n**React 19 with the React Compiler auto-memoizes**, so blanket defensive `useMemo`\u002F`useCallback`\u002F`memo` is now an anti-pattern, not a best practice — it adds noise and the compiler already handles the common cases. Manual memo is the exception, and you justify it with a profile.\n\n- Profile with the **React DevTools Profiler**: record an interaction, find the component that re-rendered, read \"why did this render\" and its render time.\n- **The 16 ms rule:** one frame at 60 fps is ~16 ms. If a manual memo saves less than that, skip it — you can't see it and you're paying for the cache.\n- The compiler **cannot** fix a new object\u002Farray\u002Ffunction reference created in render and passed as a prop — that's a fresh identity every time. Hoist it or derive it stably; that's the real fix, not wrapping the consumer in `memo`.\n\n**RSC boundary discipline.** React Server Components ship zero JS for non-interactive trees; teams report 50–70% First-Load-JS cuts from full RSC adoption. The `'use client'` directive is a *boundary*: everything imported below it becomes client code. So push interactivity into the smallest leaf component and keep data fetching and layout on the server.\n\n```tsx\n\u002F\u002F Bad: 'use client' at the top of the route — the whole tree ships to the browser\n\"use client\";\nexport default function ProductPage({ data }) {\n  \u002F* layout, data display, and one tiny button all client-side *\u002F\n}\n\n\u002F\u002F Good: server component holds data\u002Flayout; only the interactive leaf is a client component\nexport default function ProductPage({ data }) {       \u002F\u002F server: zero JS\n  return (\n    \u003Carticle>\n      \u003CProductDetails data={data} \u002F>                  {\u002F* server *\u002F}\n      \u003CAddToCartButton id={data.id} \u002F>                {\u002F* the only 'use client' file *\u002F}\n    \u003C\u002Farticle>\n  );\n}\n```\n\nUse **streaming SSR with `\u003CSuspense>`** to flush the static shell immediately and stream slow subtrees in parallel — multiple independent boundaries stream concurrently, cutting time-to-first-paint when one section is data-bound. The canonical App-Router data and component patterns are `..\u002Fnextjs\u002FSKILL.md` and `..\u002Freact\u002FSKILL.md`; bring the perf loop here, take the idioms there.\n\n## Anti-patterns\n\n| Anti-pattern | Why it's wrong | Do instead |\n|---|---|---|\n| Optimizing on a hunch, no profile | you fix a phase nobody waits on | measure → attribute → fix the dominant phase |\n| Chasing a lab score no real user hits | lab cold-cache LCP ≠ field p75 | optimize the field 75th-percentile number |\n| Reporting the mean, not p75 | the average hides the tail users feel | always read\u002Freport the 75th percentile |\n| Blanket `useMemo`\u002F`useCallback` in React 19 | the compiler already memoizes; you add noise | memo only what the Profiler proves >16 ms |\n| Lazy-loading the LCP \u002F hero image | you defer the very element LCP measures | `priority` \u002F `fetchpriority=high`, eager |\n| `import _ from \"lodash\"` for one function | the whole library lands in First Load JS | named import or a few lines of your own |\n| `'use client'` at the top of the tree | the entire subtree ships to the browser | push the boundary to the interactive leaf |\n| Images\u002Fembeds with no reserved space | content reflows on load → CLS | explicit width\u002Fheight or `aspect-ratio` |\n| Micro-optimizing a non-bottleneck phase | effort moves a number off the critical path | fix only the phase the trace points at |\n| \"Done\" without re-measuring | the fix may not have moved the metric | re-measure against the threshold, then stop |\n| Reporting source-only review as a measured win | no trace\u002Ffield\u002Fbenchmark ran, so the number is invented | label POTENTIAL and name the measurement |\n| Changing three levers in one experiment | you cannot attribute the result or reuse the learning | one hypothesis\u002Fchange per card, then re-measure |\n| Keeping a neutral optimization | complexity rose but the target did not beat normal variance | targeted revert; retain the failed-experiment record |\n\n## Stop rule\n\nYou are done when the **field 75th percentile clears the \"good\" threshold** (LCP ≤ 2.5 s, INP ≤ 200 ms, CLS ≤ 0.1) and your bundle is under its budget — re-measure to confirm, then stop. Going from \"good\" to \"slightly better good\" is gold-plating: it costs maintenance and moves a number no user notices. Commit the threshold as a budget so it can't silently regress (`scripts\u002Fverify.sh` lints that budget; see `references\u002Fprofiling-playbook.md` for the field-RUM wiring that keeps the p75 honest in production).\n",{"name":5,"tags":24,"origin":33,"profiles":34,"recommends":35,"description":7},[5,25,26,27,28,29,30,31,32],"core-web-vitals","lcp","inp","cls","bundle-size","profiling","react","web-vitals","risco",[],[36,37,38,39,31,40,41],"scaling","postgresdb","redis","nextjs","observability","monitoring","main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","06-前端与设计\u002Fperformance",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill performance",{"tool":56,"command":57},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill performance",{"tool":59,"command":60},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill performance","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Fperformance\u002FSKILL.md",true,[64,70,74],{"path":65,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":68,"sourceHtmlUrl":69},"evals\u002Fcases.yaml","REFERENCE","参考文档",4274,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Fperformance\u002Fevals\u002Fcases.yaml",{"path":71,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":72,"sourceHtmlUrl":73},"evals\u002FREADME.md",1069,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Fperformance\u002Fevals\u002FREADME.md",{"path":75,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002Fprofiling-playbook.md",4116,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Fperformance\u002Freferences\u002Fprofiling-playbook.md",[79,86,91,98,105,112],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],{"skillNo":87,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":19},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":19},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":19},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]