'Reduce JS Bundle Size by Dynamically Importing es6 Modules' javascript webperformance
One way to reduce JavaScript bundle size is to dynamically import es6 modules which are not required for the initial loading of the page. It is similar toTo dynamically import a module, the import keyword to be called as a function with a path to the module as an argument, when you dynamically import a module, you will get a promise that will resolve to an “all modules” object and you can get the corresponding exported function from the “all module” object.
const moduleSpecifier="path_to_module" import.then=> { // allModules will have all the modules exported from the file specified in the path, it is similar to import * as allModules from 'path_to_module' allModules.
Here we don't need to import the validation function statically in the initial bundle because the validation function needs to be called only when the user starts filling the form or when the user submits the form, so instead of static import, we can import it dynamically when the user starts typing or when the user clicks on the submit buttonimport { useState } from "react"; const moduleSpecifier=".
Dynamic import of es6 modules will be useful when you want to load and show a plugin/widget based on a configuration, you can lazily load the modules based on the configuration instead of loading all modules statically, this helps in better loading time and reduce bloating of the web app.
Indonesia Berita Terbaru, Indonesia Berita utama
Similar News:Anda juga dapat membaca berita serupa dengan ini yang kami kumpulkan dari sumber berita lain.
White House working to 'reduce the tension' over Putin's nuclear threatsWhite House press secretary Jen Psaki claimed Monday that the Biden administration is working to 'reduce the tension' caused by apparent nuclear threats made by Russian President Vladimir Putin.
Baca lebih lajut »
White House wants to 'reduce the rhetoric and deescalate' after Putin's nuclear deterrence moveThe Biden administration wants to “reduce the rhetoric and deescalate” after Russian President Vladimir Putin ordered his country’s deterrence forces – which include nuclear arms – to be placed on high alert, the White House said.
Baca lebih lajut »
This new competitor to the ARK Innovation ETF focuses on disruptive companies but aims to reduce volatilityThe Harbor Disruptive Innovation ETF takes a broad approach to stock selection.
Baca lebih lajut »
New 2022 BMW 2 Series Coupe priced from £34,980 | AutocarDynamically focused two-door gets three powertrains from launch, including hot 369bhp M240i
Baca lebih lajut »
The Trouble with FIPS | HackerNoonFIPS 140 sets the standard for cryptography used in the United States, but it's got problems. Because of FIPS, we all have problems.
Baca lebih lajut »
4 Coding Practices I’ve Picked Up Working for a Startup | HackerNoon'4 Coding Practices I’ve Picked Up Working for a Startup' programming javascript
Baca lebih lajut »