Describe different types and uses of JavaScript modules. Which JavaScript modules are suited for which tasks?
- This is a question for the certification study guide.
- I know it's kind broad, but still there is no direct answer on this in the docs.
This is what I found in the Swift Otter guide.
Magento 2 utilizes RequireJS to create a modular and extensible system in JavaScript. Javascript modules can be completely custom, can extend a UI Component module, or be a jQuery widget. They can be asynchronously loaded or embedded directly in a page using a plain tag. Magento’s allows for loading modules and passing even complex configuration info into them. These modules handle much interaction between the website user and the Magento PHP application. Using Javascript to load aspects of customer data is ideal because it allows Magento to cache the full page. You can keep all blocks cacheable and load in the customer-specific information in an AJAX request. For work with grids and forms in the admin panel or the checkout, a UI Component Javascript module would be a good approach. For using KnockoutJS for a customer area, a simple module that is initialized through would work well. For handling smaller DOM manipulation tasks, a module that creates a jQuery widget would be good.
I would say that the Javascript Module types are ui components, jquery widgets and plain javascript components.
Any opinions, hints, resources (I looked through the docs, in my opinion the JS part skips on the fundamentals)