Menu Close
    Hire us Request quote Reading list Switch to dark mode

    How to use javascript in magento2

    Here we learn how to use javascript in magento2

    1# First we will create requirejs-config.js file in folder app/code/NameSpace/Module/view/frontend


    In case of add js file in admin section  you need to create this above file in app/code/NameSpace/Module/view/adminhtml folder

    2# Now i’ll create javascript file which i want to use

    create ‘customjsfile.js’ file in app/code/NameSpace/Module/view/frontend/web/js

    3# Now we’ll call this javascript file on phtml file.

    add following code in our phtml file where we want to use javascript


    after these steps flush cache and check your page where you add this javascript .

    Thanks …

    . . .

    Comment

    Add Your Comment

    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just received your message and our expert will get back to you shortly.
    Send Again
    Close