---
title: "Loading Ads with the Script Component"
description: "Learn to lazy load ads using the Next.js Script Component."
url: "https://vercel.com/templates/next.js/script-component-ad"
links:
  repository: "https://github.com/vercel/examples/tree/main/solutions/script-component-ad"
  demo: "https://solutions-script-component-ad.vercel.app"
  deploy: "https://vercel.com/new/clone?demo-title=Loading+Ads+with+the+Script+Component&demo-description=Learn+to+lazy+load+ads+using+the+Next.js+Script+Component.&demo-url=https%3A%2F%2Fsolutions-script-component-ad.vercel.app&project-name=script-component-ad&repository-name=script-component-ad&repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fexamples%2Ftree%2Fmain%2Fsolutions%2Fscript-component-ad&demo-image=%2F%2Fimages.ctfassets.net%2Fe5382hct74si%2F55i1MDfEljE44p56pybntS%2Fa9edbf88dee8fb00a0dc94972ed11b41%2Fsolutions-script-component-ad.vercel.app_.png"
---

# Loading Ads with the Script Component

Learn to lazy load ads using the Next.js Script Component.

This example shows how to lazy load ads using the [Next.js Script Component](https://nextjs.org/docs/basic-features/script).

## Demo

https://solutions-script-component-ad.vercel.app

## How to Use

You can choose from one of the following two methods to use this repository:

### Clone and Deploy

Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:

```bash
npx create-next-app --example https://github.com/vercel/examples/tree/main/solutions/script-component-ad
# or
yarn create next-app --example https://github.com/vercel/examples/tree/main/solutions/script-component-ad
```

Next, run Next.js in development mode:

```bash
npm install
npm run dev

# or

yarn
yarn dev
```

Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=edge-middleware-eap) ([Documentation](https://nextjs.org/docs/deployment)).

## Related Templates

### [Experimentation with Statsig](https://vercel.com/templates/next.js/ab-testing-statsig)

Reduce CLS and improve performance from client-loaded experiments with Statsig

### [Blue-Green Deployments on Vercel](https://vercel.com/templates/next.js/blue-green-deployments-vercel)

See how Vercel's Skew Protection feature enables production-ready blue-green deployments with just a few lines of code.

### [A/B Testing Simple](https://vercel.com/templates/next.js/ab-testing-simple)

By A/B testing at the edge, you'll reduce CLS from client-loaded experiments and improve your site's performance with smaller JS bundles.

---

## Additional documentation

The [Vercel Knowledge Base](https://vercel.com/kb) contains guides and answers to common questions about Vercel, including deployment, framework configuration, domains, caching, and troubleshooting.
