0

Below is code of my default.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="My_Slider::css/betterslider.css"/>
    </head>
</page>

i want css to be loaded js before body end tag , how can this be done please help with same.

0

I don't have enough reputation yet to mark this question as a duplicate or to add this as a comment, but here's a cross-reference to an answer: Magento 2 add script before closing body tag

0
  1. app/design/frontend/{Vendor}/{theme}/Magento_Theme/layout/default.xml

    <referenceContainer name="before.body.end">
        <block class="Magento\Framework\View\Element\Template" name="beforebodyend.css.file" template="Magento_Theme::html/before_body_end_css.phtml" />
    </referenceContainer>
    
  2. app/design/frontend/{Vendor}/{theme}/Magento_Theme/templates/html/before_body_end_css.phtml

    <link rel="stylesheet" type="text/css" href="<?php echo $block->getViewFileUrl('css/betterslider.css')?>">
    
  3. app/design/frontend/{Vendor}/{theme}/web/css/betterslider.css

    .class {
         ....
    }
    
Don't forget to flush the cache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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