If you’re using webpack to bundle your application, then you can use webpack magic comments to have webpack instruct the browser to prefetch dynamic imports.
Next.js supports ES2020 dynamic import() for JavaScript. With it, you can import JavaScript modules dynamically and work with them. They also work with SSR.
// remove this importimport { javascript } from"@codemirror/lang-javascript"// add this where needed access to {javascript}constjavascript= (awaitimport("@codemirror/lang-javascript")).javascript;
Dynamically import the Hello component with loading component:
React-Loadable - a higher-order component for dynamically loading a module before rendering it, a loading component is rendered while the module is unavailable.