IIFE < CommonJS < ES6 modules

There’s one more difference between CommonJS modules and ES Modules that we didn’t cover above.

With CommonJS (require) , you can require a module anywhere, even conditionally.

if (pastTheFold === true) {  require('./parallax') }

Because ES Modules (import) are static, import statements must always be at the top level of a module. You can’t conditionally import them.

if (pastTheFold === true) 
{
import './parallax'
// "import' and 'export' may only appear at the top level" }

Experience with Front-end Technologies and MERN / MEAN Stack. Working on all Major UI Frameworks like React, Angular.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store