JS Interview Question: What do you think of AMD vs CommonJS?

What do you think of AMD vs CommonJS?

RLyn Ben
2 min readJan 8, 2016

AMD and CommonJS are both Javascript module loader. They accomplish the same task but works different.

AMD is better for browser, hence, the name ‘Asynchronous’, as it loads each distinct module in async manner instead of loading in one large file. No extra steps are required to use AMD, it works out-of-the-box. In my opinion, as it is its in Asynchronous nature, it makes alot of async http requests and may not be as performant as described by other devs.

While, CommonJS, is a standard, mostly used in servers and it loads modules synchronously, though extra step is required if you want your JS file size to be minified and compressed.

Why do we need to use Javascript module loader?

Usually, JS files are loaded in order via script tag in HTML templates, but files and code gets complicated once an application becomes large. Javascript module loaders lets us separate our code into modules and include a specific module in another module. This lets us import what module is required and load only the necessary. Better Javascript file size load and better code compartmentalization, means, JS module loader mitigates away the danger of global-namespace issue.

Also

If you are looking for a platform to develop your clients’ website, check out my SAAS platform https://ecompurpl.com :)

EcomPurpl.com is the all-in-one solution for anyone looking to create a website. Templates, E-Commerce, Hosting, Galleries, Booking & Appointments, CRM, 24/7 support, and integration of your app are all included.

--

--

RLyn Ben
RLyn Ben

Written by RLyn Ben

Software Engineer / Front-End Dev. Currently resides in Las Vegas. https://ecompurpl.com

No responses yet