Unit 4. Modules

Until recently, most front-end applications followed the same paradigm for using libraries: exposing globals. For example, if someone wanted to use jQuery (https://jquery.com) in a project, they would need to go to jQuery’s website, download either jquery.js or jquery.min.js, add it to their projects’s js or vendor folder, and then include a <script> tag importing the library into their application. This was not ideal, because it required modules to export themselves using global variables that could potentially collide with other global variables. It also required dependencies to be included before any library that relied on them or there would be an error.

Modules solve these problems by allowing scripts to be included by ...

Get Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.