3

But script moving to inside body tag how to fixes this issue? Anyone can help me for this

<referenceContainer name="head.additional">
   <block class="Magento\Framework\View\Element\Template" name="custom_js" template="Magento_Theme::html/mycustomjs.phtml" before="-"/>
</referenceContainer> 
1

1 Answer 1

1

app/code/Vendorename/Modulename/view/frontend/layout

default_head_blocks.xml

<?xml version="1.0"?>


<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="Vendorename_Modulename::css/customcss.css" />
    </head>
    <body>
    </body>
</page>

Place your css at app/code/Vendorename/Modulenaee/view/frontend/web/css/customcss.css

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.