Onze vrijwilligers hebben dit artikel nog niet naar het Nederlands vertaald. Doe mee en help de klus te klaren!
U kunt het artikel ook in het English (US) lezen.

The import statement is used to import functions, objects or primitives that have been exported from an external module, another script, etc.

Note: This feature is not implemented in any browsers natively at this time. It is implemented in many transpilers, such as the Traceur Compiler, Babel, Rollup or Webpack.


import defaultMember from "module-name";
import * as name from "module-name";
import { member } from "module-name";
import { member as alias } from "module-name";
import { member1 , member2 } from "module-name";
import { member1 , member2 as alias2 , [...] } from "module-name";
import defaultMember, { member [ , [...] ] } from "module-name";
import defaultMember, * as name from "module-name";
import "module-name";
Name of the object that will refer to the imports.
member, memberN
Name of the exported members to be imported.
Name which will refer to the default export from the module.
alias, aliasN
Names which will refer to the named imports.
The name of the module to import.


The name parameter is the name which will refer to the exported members. The member parameters specify individual members, while the name parameter imports all of them. Below are examples to clarify the syntax.

Import an entire module's contents. This inserts myModule into the current scope, containing all the exported bindings from the module identified by "my-module", often "my-module.js".

import * as myModule from 'my-module';

Import a single member of a module. This inserts myMember into the current scope.

import {myMember} from 'my-module';

Import multiple members of a module. This inserts both foo and bar into the current scope.

import {foo, bar} from 'my-module';

Import a member with a more convenient alias. This inserts shortName into the current scope.

import {reallyReallyLongModuleMemberName as shortName}
  from 'my-module';

Import an entire module for side effects only, without importing any bindings.

import 'my-module';

Import multiple members of a module with convenient aliases.

import {
  reallyReallyLongModuleMemberName as shortName,
  anotherLongModuleName as short
} from 'my-module';

Importing defaults

It is possible to have a default export (whether it is an object, a function, a class, etc.). The  import statement may then be used to import such defaults.

The simplest version directly imports the default:

import myDefault from 'my-module';

It is also possible to use the default syntax with the ones seen above (namespace imports or named imports). In such cases, the default import will have to be declared first. For instance:

import myDefault, * as myModule from 'my-module';
// myModule used as a namespace


import myDefault, {foo, bar} from 'my-module';
// specific, named imports


Importing a secondary file to assist in processing an AJAX JSON request.

// --file.js--
function getJSON(url, callback) {
  let xhr = new XMLHttpRequest();
  xhr.onload = function () { 
  xhr.open('GET', url, true);

export function getUsefulContents(url, callback) {
  getJSON(url, data => callback(JSON.parse(data)));

// --main.js--
import { getUsefulContents } from 'file';
getUsefulContents('http://www.example.com', data => {


Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Imports' in that specification.
Standard Initial definition.
ECMAScript Latest Draft (ECMA-262)
The definition of 'Imports' in that specification.

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support 60 (flag)[2][5] 38 (14.14342) (flag)[3][5] 54 (54) (flag)[1][5] No support 47 (flag)[6] 10.1[4][5]
Feature Android Android Webview Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support No support 36.0 No support No support 47(flag)[6] No support 60(flag)[6]

[1] See bug 568953.

[2] See Chromium bug 1569

[3] Behind the "Enable experimental JavaScript features" flag(about:flags)

[4] See Safari Technical Preview 21 Release Notes

[5] See ECMAScript modules in browsers

[6] See Modules (ES6) - Chrome Platfrom Status

See also