Menu Close
    Start a Project 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 …

    . . .


    Add Your Comment

    Be the first to comment.

    Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again