Answer the question
In order to leave comments, you need to log in
How to work with JS in Magento?
I figured out how to include scripts in phtml template files with require js, this is understandable. But in magento there is a way to connect via x-magento-init, I didn’t understand from the documentation in which cases to use this method and where should the included file be located?
I connect like this
<script type="text/x-magento-init">
{
"*": {
"Magento_Catalog/js/product/counter.js": {}
}
}
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question