The use of JavaScript in web application projects has evolved in recent years because of the functionalities, facilities, and portability that this technology provides to users.
The inclusion of the JavaScript files was made exclusively through insertion in the page headers, which has caused a big problem in performance and page loading.
In previous versions of Magento it was discussed in relation to good practice using the JavaScript and standardization of use of libraries, such as jQuery (http://jquery.com/) and Prototype (http://prototypejs.org/). In order to provide greater management power and performance of JavaScript, Magento 2 uses RequireJS (http://requirejs.org/) as a standard to load JavaScript libraries.
RequireJS is a JavaScript file and module loader and it implements the standard and Asynchronous Module Definition (AMD). This type of pattern allows JavaScript to run without it to be declared in a global scope, such as layout configuration files...