Przejdź do głównej zawartości

noSyncScripts

Ta treść nie jest jeszcze dostępna w Twoim języku.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noSyncScripts": "error"
}
}
}
}

Prevent the usage of synchronous scripts.

A synchronous script can impact your webpage performance, read more on how to Efficiently load third-party JavaScript.

const Invalid = () => <script src="https://third-party-script.js" />;
code-block.jsx:1:23 lint/nursery/noSyncScripts ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Unexpected synchronous script.

> 1 │ const Invalid = () => <script src=“https://third-party-script.js” />;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

Synchronous scripts can impact your webpage performance. Add the “async” or “defer” attribute. If using Next.js, consider the Script component instead.

const Valid = () => {
return (
<>
<script src="https://third-party-script.js" async />
<script src="https://third-party-script.js" defer />
</>
);
}
import Script from 'next/script'
const Valid = () => <Script src="https://third-party-script.js" />;