Performance: ES Modules import and export
MEDIUM IMPACT
This concept affects the initial load time and parsing speed of JavaScript modules in the browser or Node.js environment.
import { calculate } from './utils.js'; const result = calculate();
import * as utils from './utils.js'; const result = utils.calculate();
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Import entire module with * | N/A | N/A | Increases script parsing time | [X] Bad |
| Import specific exports statically | N/A | N/A | Smaller script size, faster parsing | [OK] Good |
| Dynamic import for rarely used code | N/A | N/A | Defers loading, improves initial paint | [OK] Good |
| Static import of large unused modules | N/A | N/A | Blocks initial load, increases LCP | [X] Bad |