ES6 import a file in multiple place, why the file loads once?

Viewed 2666

If there has a common file named common.js, and others such as a.js, b.js...

common.js

const Common = { property: 'initial' }
export { Common };

a.js

import { Common } from 'common.js';
Common.property = 'changed';

b.js

import { Common } from 'common.js';
console.log(Common.property);

First, a.js runs and load the common.js into memory.

Then, b.js run by engine.

  1. Does the common.js will load again or use the existing common.js in the memory?
  2. If common.js was updated by other xx.js script, how will the import behave?
2 Answers
Related