rsnext/errors/no-sync-scripts.mdx
Delba de Oliveira 44d1a1cb15
docs: Migrate error messages to MDX and App Router. (#52038)
This PR is part of a larger effort to migrate error messages to MDX and
use App Router: https://github.com/vercel/front/pull/23459
2023-07-05 06:11:16 -07:00

39 lines
752 B
Text

---
title: No Sync Scripts
---
> Prevent synchronous scripts.
## Why This Error Occurred
A synchronous script was used which can impact your webpage performance.
## Possible Ways to Fix It
#### Script component (recommended)
```jsx filename="pages/index.js"
import Script from 'next/script'
function Home() {
return (
<div class="container">
<Script src="https://third-party-script.js"></Script>
<div>Home Page</div>
</div>
)
}
export default Home
```
#### Use `async` or `defer`
```html
<script src="https://third-party-script.js" async />
<script src="https://third-party-script.js" defer />
```
## Useful Links
- [Efficiently load third-party JavaScript](https://web.dev/efficiently-load-third-party-javascript/)