sfnext-performance
БесплатноБез исполняемых скриптовНе проверенKeep a Storefront Next storefront fast and self-review changes for performance: LCP, CLS and TBT, Suspense placement and granularity, stable promise identity…
от SalesforceCommerceCloud★ 58 звёзд на GitHubОб этом скилле
Storefront Next Performance
Performance rules are part of AGENTS.md ("Performance & Data Rules") and detailed in docs/README-PERFORMANCE.md, docs/README-SUSPENSE.md, docs/README-IMAGES.md and docs/README-PERFORMANCE-METRICS.md in your project. This skill is the working summary plus a checklist to run on your own diff: PERFORMANCE-REVIEW-CHECKLIST.md.
Core rules
- Server-load data. Await only what SEO, LCP, layout or the HTTP status needs; return promises for the rest (see
storefront-next:sfnext-data-fetching). - One
<Suspense>per async operation, with a skeleton that reserves the final size. Nofallback={null}above the fold unless space is reserved. - Promise identity must be stable across renders: compose in the loader, read from
loaderData/props, neverPromise.all/.then/new Promisein render, neveruseMemoaround a promise. Escape hatches:useState(() => ...)pinning oruseRefre-pinning. - Every
use()/<Await>consumer needs a<Suspense>ancestor; otherwise it blocks the first byte of the streamed shell. - Heavy or hidden UI (modals, drawers, dialogs, rich editors) is
React.lazyand mounted only while needed. - Shape data in the loader, not in render.
- Hints and third-party scripts cost: preconnect only to origins used on every page; load scripts
async/defer.
Lazy modals and drawers
import { lazy, Suspense, useState } from 'react';
import { useDeferredUnmount } from '@/hooks/use-deferred-unmount';
const SizeGuide = lazy(() => import('@/components/size-guide').then((m) => ({ default: m.SizeGuide })));
export function SizeGuideButton() {
const [open, setOpen] = useState(false);
const mounted = useDeferredUnmount(open); // stays mounted briefly after close for the exit animation
return (
<>
<button onClick={() => setOpen(true)}>Size guide</button>
{mounted && (
<Suspense fallback={null}>
<SizeGuide open={open} onOpenChange={setOpen} />
</Suspense>
)}
</>
);
}
Avoid a sticky "loaded" latch (a state that flips true on first open and never resets): fetchers inside the modal stay registered and re-run on every later revalidation. See src/components/product-tile/quick-add-button.tsx.
Deferred rendering
useDeferredRender(enabled, options) (@/hooks/use-deferred-render) delays mounting a Suspense boundary until an idle frame; use it for large below-the-fold grids. DeferredProductGrid (@/components/product-grid/deferred) is the reference. useDeferredRenderSequence(n) fans out work one step per idle frame.
Page Designer
Mark a region <Region critical> only when it is required for the initial HTML or is an LCP candidate, and await that page in the loader (omit a region fallback). Below-the-fold regions stay streamed. See storefront-next:sfnext-page-designer.
Images, fonts, hints
- Images: use
DynamicImage(@/components/dynamic-image). Props:src,alt,widths,heights,imageProps,as,className,loading,priority,objectFit. Give the LCP imagepriority="high"(React 19 preload) and never lazy-load it. Providewidthsmatching the layout, or wrap a group inDynamicImageProvider(@/providers/dynamic-image,value={{ widths }}). URL helpers are indocs/README-IMAGES.md. - Fonts: the template self-hosts
public/fonts/sen-variable.woff2, preloads it insrc/root.tsxlinks, and declares@font-facewithfont-display: swapinsrc/theme/base.css. Keep fonts same-origin, preload only the one above-the-fold face, and consider system fonts for secondary text. - Resource hints: configure
app.links.preconnect,prefetchDns,prefetchinconfig.server.tsor viaPUBLIC__app__links__preconnect='["https://cdn.example.com"]'. Default preconnects to the image host only.
Measure
| Task | Command |
|---|---|
| Check bundle size limits (block CI) | pnpm bundlesize |
Interactive treemaps (build/client-bundle-size.html, build/ssr-bundle-size.html) |
cross-env BUNDLES_SIZE_ANALYZE=true pnpm build |
| Compare size runs | pnpm bundlesize:compare |
| Lighthouse | pnpm lighthouse:ci |
| Request timings | performance.metrics flags in config.server.ts |
The limits live in the bundlesize block of package.json. If a legitimate change exceeds a limit, state the reason and raise it deliberately; do not use manualChunks to bucket components.
performance.metrics (serverPerformanceMetricsEnabled, serverTimingHeaderEnabled, clientPerformanceMetricsEnabled) are all false in the shipped config.server.ts; docs/README-PERFORMANCE-METRICS.md lists two of them as defaulting to true, but the shipped config wins. Enable them only while debugging, because serverTimingHeaderEnabled adds a Server-Timing header and costs response time. Override via PUBLIC__app__... environment variables (`storef
Установить sfnext-performance в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл sfnext-performance?
Keep a Storefront Next storefront fast and self-review changes for performance: LCP, CLS and TBT, Suspense placement and granularity, stable promise identity, lazy-loaded modals and drawers with useDeferredUnmount, useDeferredRender, Region critical, DynamicImage and image priority, font loading, resource hints (links.preconnect), bundle size checks (pnpm bundlesize, BUNDLES_SIZE_ANALYZE), Lighthouse CI, and the performance.metrics / Server-Timing flags. Use for "page is slow", "LCP regression", "skeleton flashes", "bundle too big", "review my diff for performance", "hydration mismatch or extra re-renders", "waterfall of fetches", or before merging feature work that adds loaders, fetchers, modals and drawers or images. Do not use for loader/action mechanics (use `storefront-next:sfnext-data-fetching`), revalidation policy (use `storefront-next:sfnext-revalidation`), or accessibility (use `storefront-next:sfnext-accessibility`).
Как установить скилл sfnext-performance?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sfnext-performance запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic