NEXTJS_NO_BEFORE_INTERACTIVE
Requires review of usage of the beforeInteractive strategy in Script (next/script) elements.
Conformance Rules
View All Rules BFCACHE_INTEGRITY_NO_UNLOAD_LISTENERS BFCACHE_INTEGRITY_REQUIRE_NOOPENER_ATTRIBUTE ESLINT_CONFIGURATION ESLINT_NEXT_RULES_REQUIRED ESLINT_REACT_RULES_REQUIRED ESLINT_RULES_REQUIRED NEXTJS_MISSING_MODULARIZE_IMPORTS NEXTJS_MISSING_OPTIMIZE_PACKAGE_IMPORTS NEXTJS_MISSING_NEXT13_TYPESCRIPT_PLUGIN NEXTJS_MISSING_REACT_STRICT_MODE NEXTJS_MISSING_SECURITY_HEADERS NEXTJS_NO_BEFORE_INTERACTIVE NEXTJS_NO_CLIENT_DEPS_IN_MIDDLEWARE NEXTJS_NO_DYNAMIC_AUTO NEXTJS_NO_FETCH_IN_SERVER_PROPS NEXTJS_NO_GET_INITIAL_PROPS NEXTJS_NO_SELF_HOSTED_VIDEOS NEXTJS_NO_TURBO_CACHE NEXTJS_SAFE_SVG_IMAGES NEXTJS_SAFE_URL_IMPORTS NEXTJS_UNNEEDED_GET_SERVER_SIDE_PROPS NEXTJS_NO_ASYNC_PAGE NEXTJS_NO_ASYNC_LAYOUT NEXTJS_USE_NATIVE_FETCH NEXTJS_NO_PRODUCTION_SOURCE_MAPS NEXTJS_USE_NEXT_FONT NEXTJS_USE_NEXT_IMAGE NEXTJS_USE_NEXT_SCRIPT NO_ASSIGN_WINDOW_LOCATION NO_CORS_HEADERS NO_DANGEROUS_HTML NO_DOCUMENT_WRITE NO_EVAL NO_EXTERNAL_CSS_AT_IMPORTS NO_FETCH_FROM_MIDDLEWARE NO_INSTANCEOF_ERROR NO_MIXED_ASYNC_MODULES NO_SERIAL_ASYNC_CALLS NO_VARIABLE_IMPORT_REFERENCES PACKAGE_JSON_DESCRIPTION_REQUIRED PACKAGE_JSON_DUPLICATE_DEPENDENCIES PACKAGE_JSON_NAME_REQUIRED PACKAGE_JSON_PRIVATE_REQUIRED PACKAGE_JSON_SIDE_EFFECTS_REQUIRED PACKAGE_JSON_TYPE_REQUIRED PACKAGE_MANAGEMENT_NO_CIRCULAR_IMPORTS PACKAGE_MANAGEMENT_NO_UNRESOLVED_IMPORTS PACKAGE_MANAGEMENT_REQUIRED_README REACT_NO_STATIC_IMPORTS_IN_EVENT_HANDLERS REACT_STABLE_CONTEXT_PROVIDER_VALUE NEXTJS_REQUIRE_EXPLICIT_DYNAMIC REQUIRE_DOCS_ON_EXPORTED_FUNCTIONS REQUIRE_ONE_VERSION_POLICY REQUIRE_NODE_VERSION_FILE SET_COOKIE_VALIDATION TESTS_NO_CONDITIONAL_ASSERTIONS TESTS_NO_ONLY TYPESCRIPT_CONFIGURATION TYPESCRIPT_ONLY WORKSPACE_MISSING_CONFORMANCE_SCRIPT WORKSPACE_MISSING_PACKAGE_JSON
The default loading strategy
for next/script
is optimised
for fast page loads.
Setting the strategy to beforeInteractive
forces the script to load before any Next.js code and before hydration occurs,
which delays the page from becoming interactive.
For further reading, see:
This rule will catch the following code.
import Script from 'next/script' ;
export default function MyPage () {
return (
< Script src = "https://example.com/script.js" strategy = "beforeInteractive" />
);
}
This rule flags any usage of beforeInteractive
for review. If approved, the
exception should be added to the allowlist.
Last updated on July 23, 2024