# Introduction to modern modules in JavaScript

You've already worked with modules via closures. In modern JavaScript, more handy modules have appeared that allow you to place each module in a separate file, and then, if necessary, connect to other files, exporting only necessary variables and functions.

Initially, such modules were not fixed in the JavaScript standard and were simply developed by the community. Accordingly, a lot of different modular systems have appeared: AMD, CommonJS, UMD and others.

Then the JavaScript standard introduced its own modules. They are called ES modules. Because of this, the modules developed by the community are rapidly outdated and shouldn't be used.

You should pay attention only to the CommonJS modules, since NodeJS originally worked with them, and now it works with them by default for compatibility purposes.

In addition, often in documentation for enabling various libraries you will find a description of the CommonJS version, and not ES. Therefore, you should imagine how to remake the CommonJS code for ES.

There is another nuance. Although modules are now fixed in the JavaScript standard, they just won't work in the browser (yet). To do this, you need to use one of the popular build tools.

← →
↑
en ru