What is the proper way to add a script before the closing body tag in magento 2?
I want it to be available to all pages.
UPDATE:
I've got in myvendor/mytheme/Magento_Theme/layout/default.xml
with:
<referenceContainer name="before.body.end">
<block class="\Magento\Framework\View\Element\Template" template="Theme_Module::js.phtml" name="module_js"/>
</referenceContainer>
And the js.phtml
inside /Magento_Theme/templates
Should that be right?
Best Answer
You can do it with layout
and in js.phtml