In my Magento site, we found there was configuration in admin.

Admin -> Store -> Configuration -> Advanced -> Developer (Enabled only on Developer mode). JavaScript settings -> Move JS code to the bottom of the page

When this is YES, all the scripts tags on the site moves to the bottom of the page.

But I need to include a script which shouldn't move to the bottom.

Is there any way to achieve this?

Thanks in advance.


3 Answers 3


I have developed a solution on my own. And submitted this as a blog.

Hope this helps for someone.


Happy Coding..!!!



To exclude a particular tag from moving to the bottom of the page, simply add type="text/x-magento-template" to the script tag and it will remain where originally inserted via layout instruction.

See vendor\magento\module-theme\Controller\Result\JsFooterPlugin.php

Line 82:: $isXMagentoTemplate = strpos($script, 'text/x-magento-template') !== false;


Edit the JsFooterPlugin.php file in /vendor/magento/module-theme/Controller/Result and include an exception in the first conditional of public function beforeSendResponse

Your Answer

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

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