TareaAdd three resource hints: preconnect 'https://cdn.example.com' (crossorigin), preload '/hero.webp' as='image' fetchpriority='high', preload '/inter.woff2' as='font' type='font/woff2' crossorigin.
precarga + preconexión para recursos críticos
100 XP7 min
Teoría
You saw this in A1 — now apply it in context
<head> <meta charset="utf-8" /> <!-- 1. tell the browser about origins we'll fetch from --> <link rel="preconnect" href="https://cdn.example.com" crossorigin /> <link rel="dns-prefetch" href="https://api.stripe.com" /> <!-- 2. high-priority fetch the LCP image --> <link rel="preload" as="image" href="/hero.webp" fetchpriority="high" /> <!-- 3. preload the hero font (so text doesn't FOUT) --> <link rel="preload" as="font" type="font/woff2" href="/inter.woff2" crossorigin /> <!-- 4. let the parser proceed --> <link rel="stylesheet" href="/critical.css" /> <script src="/app.js" defer></script> </head>
When each is worth it
- `preconnect` — when you'll fetch ≥1 thing from that origin within 5 seconds. Saves DNS + TCP + TLS handshake (~50-150ms on first request).
- `dns-prefetch` — same idea, less expensive (DNS only), less reliable. Use when you MIGHT fetch from there.
- `preload` — when a critical resource (LCP image, hero font, blocking JS module) is late-discovered. Lifts it to "highest priority" download queue.
Don't overdo preload
Every preload competes with your critical-path requests. Preload only the resource that's BLOCKING your LCP. Lighthouse warns: "Unused preload" if your preloaded thing isn't used within 3 seconds.
fetchpriority
A relatively new attribute. fetchpriority="high" on <link rel="preload"> AND on <img> lets you hint priority within the same resource type. Use on the hero image. Use low on offscreen images.
🔒
Regístrate para empezar a programar
La teoría está abierta a todos. El editor, la vista previa y el check se desbloquean con una prueba gratis de 7 días — se requiere tarjeta, cancela cuando quieras.
Registrarse — prueba gratis →Las primeras 10 lecciones de cada ruta son gratis. No se necesita tarjeta.