How can we work with knockout without having to compile the Magento every time?
I have disabled all cache and set Magento on developer mode but still, it needs to compile and clear cache.


I give you some tips to work with knockout js

1) Enable developer mode.

In developer mode, you need not static content deploy after Magento 2.2.

2) Check pub/static for files are symlink or not.

If files are symlink then you just need to delete a file from pub/static which you updated. After the page refresh, new updated files are automatically symlinked in pub/static.

i.e. You want to update file app/design/frontend/Vendor/theme/Magento_Checkout/web/js/sidebar.js Then delete this file from pub/static/frontend/Vendor/theme/en_US{language}/Magento_Checkout/js/sidebar.js

If you don't want to delete the file every time from pub/static then just open the file in a new tab and just refresh file in a browser to see updated code.

i.e. To Open file from the browser go to network tab and right click on file and open in new tab and refresh new tab after changes.

enter image description here

For this trick, you need not flush the cache of Magento even not need to flush the cache of the browser.

3) Disable browser cache as seen as above screenshot.

4) If files are not symlinked in pub/static

Change code from direct pub/static and after final changes just copy files in the main directory. And test final changes with static content deploy.

I follow this trick for the quick update any knockout js or HTML file in Magento 2.

Hope this will help you.


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.