How to passing Dynamic arguments from template to RequireJs in magento 2?

Magento template support script tag with X-MAGENTO-INIT declaration. You can pass dynamic PHP values to Javascript from a template file.

create demo.phtml file in your module to pass dynamic PHP value to Javascript, Continue reading “How to passing Dynamic arguments from template to RequireJs in magento 2?”

How to load JAVASCRIPT In a PHTML template with requirejs VIA X-MAGENTO-INIT?

Magento 2 template supports require JS declaration using X-MAGENTO-INIT. You can define require js with the Magento PHTML template file.

Require js loaded as AMD (Asynchronous module definition) based approach.
Benefit:
Declare JS using text/x-magento-init will be loaded after the page DOM is loaded completely. It will improve the page load time. Continue reading “How to load JAVASCRIPT In a PHTML template with requirejs VIA X-MAGENTO-INIT?”

How to get list of all knockout components from the pages in Magento?

You can get a list of all the used knockout components on the current page using uiRegistry.

Knockout Components will be defined using the custom module and Magento native code contains a lot of predefined knockout components like minicart, authentication, customer, etc…

You can also fetch a custom component by its name in the get() method of the uiRegistry object. Continue reading “How to get list of all knockout components from the pages in Magento?”