February 2018
Intermediate to advanced
298 pages
8h 22m
English
AMD is a specification for implementing modules in the browser. AMD is designed by keeping browser limitations in mind, that is, it imports modules asynchronously to prevent blocking the loading of a webpage. As AMD is not a native browser specification, we need to use an AMD library.
RequireJS is the most popular AMD library. Let's see an example of how to create and import modules using RequireJS. According to the AMD specification, every module needs to be represented by a separate file. So first, create a file named math.js that represents a module. Here is the sample code that will be inside the module:
define(function(){ const sum = (x, y) => x + y const sub = (x, y) => x - y const math = { findSum(a, ...Read now
Unlock full access