I tried to insert in the home page a jquery horizontal slider text scroll. What I need is to insert before body two scripts.

<script type="text/javascript" src="/jquery/marquee.js"></script>

$(function (){

What I tried so far is in example in a relative question.

In my console log I have the below errors and of course it didn't work:

JQMIGRATE: Logging is active jquery-migrate.js:21 
Uncaught TypeError: $.widget is not a function

You can see the full errors log in my site http://magentoeshop.vtsoulis.gr/index.php/

1 Answer 1


Create a xml file in your module

add below code to it

<referenceContainer name="before.body.end">
    <block class="Magento\Framework\View\Element\Text" name="beforebodyScript">
            <argument name="text" xsi:type="string"><![CDATA[<script type="text/javascript" src="//www.example.com/example-script.js"></script>]]></argument>

Also second solution is you can put your script in template file add xml code to your action layout file

<referenceContainer name="before.body.end">
        <block class="\Magento\Framework\View\Element\Template" template="Namespace_Modulename::before.phtml" name="before_body_js"/>

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.