Still confused if import is general ES6, or Node only

I always thought import was strictly a node thing. Can you use import to bring in a js function library if your not working on a Node site?

ES6 Import is standardized across almost all the major browsers (IE still don’t support it), so you can use it straight away in your browser without the need of any polyfill or JS compiler (like Babel).

Node natively support the usage of modules but it differs from the browser, mainly since the command is require.

there’s now a support for ECMAScript Modules but it’s still not exactly the same as the browsers.

1 Like

Yes, import is part of the ES6 specification. Read more about it here:

It is commonly used in Node, sure, and in apps like react – things that get complicated and involve splitting code between multiple files. But there’s no reason you couldn’t use it for your own development.

1 Like