Performance: Links function for stylesheets
MEDIUM IMPACT
This affects page load speed by controlling how and when CSS stylesheets are loaded and applied, impacting the Largest Contentful Paint (LCP).
export function links() {
return [
{ rel: 'preload', href: '/styles/global.css', as: 'style' },
{ rel: 'stylesheet', href: '/styles/global.css' },
{ rel: 'stylesheet', href: '/styles/extra.css', media: 'print', onload: "this.media='all'" }
];
}export function links() {
return [
{ rel: 'stylesheet', href: '/styles/global.css' },
{ rel: 'stylesheet', href: '/styles/extra.css' }
];
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple blocking stylesheets | Minimal | 1 reflow after all CSS loads | High paint cost due to delayed styles | [X] Bad |
| Preload critical CSS + deferred non-critical | Minimal | Single reflow after critical CSS | Lower paint cost with faster style application | [OK] Good |