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 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.