Astro

astro/static-by-default

Render framework components without a client directive unless they need interactivity, and pick the latest directive that works.

umiarkowanaręcznefe-astro

Dlaczego

A React, Vue or Svelte component used without a directive renders to HTML with no JavaScript. Each client:* directive adds the framework runtime and the component's code to the page, and client:load runs it at once, competing with the content the visitor came for. A footer, a card list or a static menu with client:load costs script and interaction delay for nothing.

Poprawka

Remove the directive when the component only displays data. Otherwise choose by need: client:load for what must work at once above the fold, client:idle for lower priority, client:visible (with rootMargin if it should be ready slightly before scrolling into view) for content further down, client:media for UI that exists only at some widths. Review by hand: only the author knows whether the component is interactive and where it sits.

Przykłady

<!-- bad -->
<Footer client:load />
<Comments client:load />
<!-- good -->
<Footer />
<Comments client:visible={{ rootMargin: '300px' }} />

Źródła

Fakty

Identyfikator
astro/static-by-default
Waga
umiarkowana
Sprawdzanie
ręczne ocenia człowiek; raport podaje to jako listę kontrolną
Dotyczy plików
astro
Tylko w projektach z
astro
Uczy jej skill
fe-astro Astro sites and islands
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

npx github:dawidolko/frontend-skills explain astro/static-by-default