Javascript ES6 import without a name [duplicate] Javascript ES6 import without a name [duplicate] vue.js vue.js

Javascript ES6 import without a name [duplicate]


To include a file without importing anything you can just drop the <name> from part of the statement:

import './bootstrap';

This will execute the target module without affecting the scope of the active module, but it may have side-effects such as declaring globals or modifying existing globals.


As stated in the MDN docs for Import a module for its side effects only:

Import an entire module for side effects only, without importing anything. This runs the module's global code, but doesn't actually import any values.

import '/modules/my-module.js';