Wydajność
perf/css-no-import
Shipped CSS does not chain stylesheets with @import; link them in the HTML or combine them in a build.
umiarkowanastatycznefe-perf-delivery
Dlaczego
The browser finds an @import only after it has downloaded and parsed the stylesheet that contains it, so each import adds a round trip before the page can render. On a mobile connection that is easily several hundred milliseconds of blank screen.
Poprawka
List each stylesheet with <link rel="stylesheet"> in <head> so they download in parallel, or let a build tool inline the imports into one file. Cascade layers work with links too: @layer reset, components; in the first file, then @layer components { … } in the others.
Przykłady
/* bad: main.css */
@import url("reset.css");
<!-- good -->
<link rel="stylesheet" href="/css/reset.css">
<link rel="stylesheet" href="/css/main.css">Źródła
Fakty
- Identyfikator
perf/css-no-import- Waga
- umiarkowana
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
csshtml- Tylko w projektach z
html- Uczy jej skill
fe-perf-deliveryJavaScript, CSS and asset delivery- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain perf/css-no-import