2

I am working on a magento 2 store. I have created a custom js file. It is inside

app/design/frontend/Napespace/Theme/web/js/custom.js

Now whenever I make any changes to my custom.js file, the change does not reflect on frontend until I run the following commands

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f

I have checked my magento installation is in developer mode. Is there a way I do not have to run above commands every time, I make some changes to my custom js file as this makes the development process too slow. I know I can write my custom js code in google console for testing but how to do it in magento so that I do not need to run these commands for every small change in js.

1

yes first run this command:

  • bin/magento cache:disable full_page layout block_html

Also inspect the page with your custom.js file and open the source file in new tab like this:

enter image description here

once you make changes to the js file, simply reload the page you opened in the "source tab" as the gif explains

Cheers

1
  • Could you also plz tell me a way for loading custom.css file without running commands. css is present inside custom theme web directory Aug 6 '20 at 18:49

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.