2

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)

1
  • Wow that is broad. So many ways in which you could read that. I'd even go as far to say that the answer to this would be based on opinion not fact. Tough questions to get certified! Commented May 25, 2019 at 21:49

1 Answer 1

2

Not a great answer this but I've got my magento 2 hat on and I'm thinking when they wrote these questions they were sifting through the developer docs. I think they mean declarative notation and imperative notation

https://devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/js_init.html

But it's an absolute guess. As to suited to which task. I'm not sure. Even as I'm typing this I have doubts about my answer.

Good luck!

In response to your comment here you go.

https://devdocs.magento.com/guides/v2.3/javascript-dev-guide/bk-javascript-dev-guide.html#js_terms

2
  • Thank you for your answer, it took me back to the docs. Apparently there is something documented. I must've missed it last night. I'm leaving the link here, if you amend your answer to include it I will accept it as the right answer devdocs.magento.com/guides/v2.3/javascript-dev-guide/… Commented May 26, 2019 at 15:06
  • No probs. Updated answer. Commented May 26, 2019 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.