worker

The ‘worker‘ strategy in NextJS ‘<Script/>’ component allows freeing up the main thread to process only critcal first party resource first. It’s an advanced usage senario and may not support all third party scripts.

If you want to use worker as a strategy, is to enable the nextScriptWorker flag in the next.config.js

JavaScript
module.exports = {
    experimental: {
        nextScriptWorkers: true,
    },
}
  • After ,Then you can use worker as strategy as follows:
JavaScript
import Script from "next/script";

export default function Page() {
    return (
        <>
            <Script
                src='https://external-script-source.com/script.js'
                strategy='worker'
            />
        </>
    );
}

Next.js Components : </h1></div>

Next JS is a React-based web framework that enables developers to build modern, dynamic web applications easily. Vercel developed it, and NextJS introduces a set of conventions and tools that streamline the developer process making it faster and more efficient.

This post will teach us about this project’s <Script> component.

Similar Reads

What are Script Components?

The ‘