---
title: "Warmup Strategy · Nuxt Scripts"
description: "Customize the preload or preconnect strategy used for your scripts."
canonical_url: "https://scripts.nuxt.com/docs/v0/guides/warmup"
meta:
  "og:description": "Customize the preload or preconnect strategy used for your scripts."
  "og:image": "https://scripts.nuxt.com/_og/d/c_Docs%2Ctitle_Warmup%2BStrategy%2Cdescription_Customize%2Bthe%2Bpreload%2Bor%2Bpreconnect%2Bstrategy%2Bused%2Bfor%2Byour%2Bscripts.%2Cheadline_Guides%2Cp_Ii9kb2NzL3YwL2d1aWRlcy93YXJtdXAi%2Cs_KZKzONyTP4Dc0EAC.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Warmup Strategy · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/d/c_Docs%2Ctitle_Warmup%2BStrategy%2Cdescription_Customize%2Bthe%2Bpreload%2Bor%2Bpreconnect%2Bstrategy%2Bused%2Bfor%2Byour%2Bscripts.%2Cheadline_Guides%2Cp_Ii9kb2NzL3YwL2d1aWRlcy93YXJtdXAi%2Cs_KZKzONyTP4Dc0EAC.png"
---

> Index of every page on this site: [llms.txt](https://scripts.nuxt.com/llms.txt)

**Guides**

# **Warmup Strategy**

[Copy for LLMs](https://scripts.nuxt.com/docs/v0/guides/warmup.md)

## Background

Nuxt Scripts will insert relevant warmup `**link**` tags to optimize the loading of your scripts. Optimizing for the quickest load after Nuxt has finished hydrating.

For example if we have a script like so:

```ts
useScript('/script.js')
```

This code will load in `**/script.js**` on the `**onNuxtReady**` event. As the network may be idle while your Nuxt App is hydrating, Nuxt Scripts will use this time to warmup the script by inserting a `**preload**` tag in the `**head**` of the document.

```html
<link rel="preload" href="/script.js" as="script" fetchpriority="low">
```

The behavior is only applied when we are using the `**client**` or `**onNuxtReady**` [**Script Triggers**](https://scripts.nuxt.com/docs/v0/guides/script-triggers). To customize the behavior further we can use the `**warmupStrategy**` option.

## `**warmupStrategy**`

The `**warmupStrategy**` option can be used to customize the `**link**` tag inserted for the script. The option can be a function that returns an object with the following properties:

-
  - `**false**` - Disable warmup.
-
  - `**'preload'**` - Preload the script, use when the script is loaded immediately.
-
  - `**'preconnect'**` or `**'dns-prefetch'**` - Preconnect to the script origin, use when you know a script will be loaded within 10 seconds. Only works when loading a script from a different origin, will fallback to `**false**` if the origin is the same.

All of these options can also be passed to a callback function, which can be useful when have a dynamic trigger for the script.

## `**warmup**`

The `**warmup**` function can be called explicitly to add either preconnect or preload link tags for a script. This will only work the first time the function is called.

This can be useful when you know that the script is going to be loaded shortly.

```ts
const script = useScript('/video.js', {
  trigger: 'manual'
})
// warmup the script when we think the user may need the script
onVisible(videoContainer, () => {
  script.warmup('preload')
})
// load it in
onClick(videoContainer, () => {
  script.load()
})
```

[Edit this page](https://github.com/nuxt/scripts/edit/0.x/docs/content/1.guides/1.warmup.md)

[Markdown For LLMs](https://scripts.nuxt.com/docs/v0/guides/warmup.md)

[**Script Triggers** Control when scripts load with Nuxt Scripts' flexible trigger system.](https://scripts.nuxt.com/docs/v0/guides/script-triggers) [**Bundling Remote Scripts** Optimize third-party scripts by bundling them with your app.](https://scripts.nuxt.com/docs/v0/guides/bundling)

**On this page **

- [Background](#background)
- [warmupStrategy](#warmupstrategy)
- [warmup](#warmup)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://scripts.nuxt.com/#website","@type":"WebSite","description":"Nuxt Scripts lets you load third-party scripts with better performance, privacy, security and DX. It includes many popular third-parties out of the box.","name":"Nuxt Scripts","url":"https://scripts.nuxt.com/","publisher":{"@id":"https://scripts.nuxt.com/#identity"}},{"@id":"https://scripts.nuxt.com/docs/v0/guides/warmup#webpage","@type":"WebPage","description":"Customize the preload or preconnect strategy used for your scripts.","name":"Warmup Strategy","url":"https://scripts.nuxt.com/docs/v0/guides/warmup","breadcrumb":{"@id":"https://scripts.nuxt.com/docs/v0/guides/warmup#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/docs/v0/guides/warmup"]}],"primaryImageOfPage":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/#identity","@type":"Organization","name":"Nuxt Scripts","url":"https://scripts.nuxt.com","logo":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/docs/v0/guides/warmup#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Nuxt Scripts","item":"https://scripts.nuxt.com/","position":1},{"@type":"ListItem","name":"Documentation","item":"https://scripts.nuxt.com/docs","position":2},{"@type":"ListItem","name":"V0","item":"https://scripts.nuxt.com/docs/v0","position":3},{"@type":"ListItem","name":"Guides","item":"https://scripts.nuxt.com/docs/v0/guides","position":4},{"@type":"ListItem","name":"Warmup Strategy","item":"https://scripts.nuxt.com/docs/v0/guides/warmup","position":5}]},{"@id":"https://scripts.nuxt.com/#logo","@type":"ImageObject","caption":"Nuxt Scripts","contentUrl":"https://scripts.nuxt.com/logo.svg","inLanguage":"en","url":"https://scripts.nuxt.com/logo.svg"}]}
```

## Sitemap

See the full [sitemap](https://scripts.nuxt.com/sitemap.md) for all pages.
