0

I wish to include custom js file in PDP page in magento 2.

I wish to do some action while product has some options. Please provide me a solution to add custom js in PDP page

0

follow below steps

1) create Magento_Catalog folder under app/design/frontend/Custom/default

2) create a layout folder and copy catalog_product_view.xml file from vendor/magento/module-catalog/view/frontend/layout and paste inside it

3) open that XML file, in head tag paste your custom js file like

Make sure your custom js file should be in app/design/frontend/Custom/default/web/js

4) run this commands php bin/magento cache:clean && php bin/magento cache:flush

check in view page source your file will be there

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.