I want to add js EXACTLY right before end of head tag
I've try this solution, but it only put the js to middle of the head tag, not right before end of head tag https://magento.stackexchange.com/a/286655/70258

1 Answer 1


You need to try the code in this way.

<referenceContainer name="head.additional">
    <block class="Magento\Framework\View\Element\Template" name="custom_head_file" template="Magento_Theme::custom_head.phtml" after="-"/>
  • Hi, thanks for reply, but this doesn't work, even if i try after="-".
    – fudu
    Commented Aug 28, 2020 at 2:03

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.