Find your content:

Search form

You are here

require vs import es6

 
Share

CommonJS
Require
module.exports

ES6
Import
Export

You can't selectively load only the pieces you need with require but with imports, you can selectively load only the pieces you need. That can save memory.

Loading is synchronous (step by step) for require but import can be asynchronous so it can perform a little better than require.

The major difference between require and import is that require will automatically scan node_modules to find modules but import which comes from ES6 don't

 

My Block Status

My Block Content