Automatically sort your head with capo.js in Astro
npm install @felixicaza/astro-capoForked from natemoo-re/astro-capo.
#### Changes made in this fork:
- Changed package name to @felixicaza/astro-capo to publish under my npm scope.
- Update order of preload tags to be higher priority and avoid CLS issues (see why).
- Added tests.
Get your in order—automatically!
@felixicaza/astro-capo is a component that automatically optimizes the order of elements in your , adapted from Rick Viscomi's wonderful capo.js library.
Unlike capo.js, which makes it easy to debug the optimal order of your in the browser, @felixicaza/astro-capo automatically optimizes your on the server while rendering your page.
⬇️ Installation
NPM:
``bash`
npm install @felixicaza/astro-capo
PNPM:
`bash`
pnpm add @felixicaza/astro-capo
Yarn:
`bash`
yarn add @felixicaza/astro-capo
Replace your regular
element with our custom component. That's it!`astro
---
import { Head } from '@felixicaza/astro-capo'
---
Astro
Astro
`💡 Why?
The previous order placed the
preload tags very low in the order, which caused some resources to be preloaded too late, for example, when there were @font-face declarations in inline style` tags, resulting in Cumulative Layout Shift (CLS) issues.This project is licensed under the MIT License. See the license file for more details.