noSyncScripts
¥Summary
-
规则生效日期:
v2.3.6¥Rule available since:
v2.3.6 -
诊断类别:
lint/nursery/noSyncScripts¥Diagnostic Category:
lint/nursery/noSyncScripts -
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 information。
¥The default severity of this rule is information.
-
来源:
¥Sources:
-
与
@next/next/no-sync-scripts相同¥Same as
@next/next/no-sync-scripts
-
¥How to configure
{ "linter": { "rules": { "nursery": { "noSyncScripts": "error" } } }}¥Description
防止使用同步脚本。
¥Prevent the usage of synchronous scripts.
同步脚本可能会影响网页性能,请阅读更多关于如何避免 高效加载第三方 JavaScript 的内容。
¥A synchronous script can impact your webpage performance, read more on how to Efficiently load third-party JavaScript.
¥Examples
¥Invalid
<script src=""></script>code-block.html:1:1 lint/nursery/noSyncScripts ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Unexpected synchronous script.
> 1 │ <script src=""></script>
│ ^^^^^^^^^^^^^^^
2 │
ℹ Synchronous scripts can impact your webpage performance. Add the “async” or “defer” attribute.
¥Valid
<script src="" async></script><script src="" defer></script><script src="" type="module"></script>¥Related links
¥Summary
-
规则生效日期:
v2.3.6¥Rule available since:
v2.3.6 -
诊断类别:
lint/nursery/noSyncScripts¥Diagnostic Category:
lint/nursery/noSyncScripts -
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 information。
¥The default severity of this rule is information.
-
此规则属于以下域:
¥This rule belongs to the following domains:
-
来源:
¥Sources:
-
与
@next/next/no-sync-scripts相同¥Same as
@next/next/no-sync-scripts
-
¥How to configure
{ "linter": { "rules": { "nursery": { "noSyncScripts": "error" } } }}¥Description
防止使用同步脚本。
¥Prevent the usage of synchronous scripts.
同步脚本可能会影响网页性能,请阅读更多关于如何避免 高效加载第三方 JavaScript 的内容。
¥A synchronous script can impact your webpage performance, read more on how to Efficiently load third-party JavaScript.
¥Examples
¥Invalid
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.
¥Valid
const Valid = () => { return ( <> <script src="https://third-party-script.js" async /> <script src="https://third-party-script.js" defer /> <script src="https://third-party-script.js" type="module" /> </> );}Next.js
Section titled “Next.js”import Script from 'next/script'
const Valid = () => <Script src="https://third-party-script.js" />;¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号