Issue with Adding Custom JavaScript


I’m encountering an issue while trying to add custom JavaScript to my Frappe app. I followed the documentation to add the custom JS, and after running bench build, the corresponding dict/js file was created. I also cleared the cache, but the script is not showing up in the frontend. I even checked the assets folder in the browser’s developer tools, but there’s no folder named my_app.

I’ll attach a screenshot for reference.


Could someone please provide guidance on how to properly add custom scripts to a Frappe app? Am I missing any steps or configurations?

Thank you!

Please put your script in the public/js/sales_invoice.js and check it.

Please check the documentation.

I’ve followed your suggestion and placed the script in public/js/sales_invoice.js, but unfortunately, it’s still not working as expected.

Additionally, I’ve taken the time to explore the ‘India Compliance’ app, and it appears they’re implementing a similar approach to what I’ve attempted. Despite this, I’m still facing issues.

please try with bench build --force

running ‘bench build --force’, but unfortunately, the issue persists.

Here’s the log from the ‘bench build’ process for your reference

something is missing but not catching here, check the path, doctype, and file name. because I added with different position/path and it’s worked properly.


I’ve carefully reviewed the path, doctype, and file name, and they all seem to be correct. Despite this, the issue persists. I’ve already enabled developer_mode, but I’m wondering if there’s any other configuration setting that could be affecting this. Do you know of any additional settings or configurations that might help resolve this issue?

I think, No

@NCP, could you provide some insight into how this thing actually works? Understanding its inner workings would greatly assist me in debugging the issue I’m currently facing. Despite following the same steps in another project of the same version where it works flawlessly,

I’m encountering persistent issues in this particular project. The main challenge lies in my lack of understanding regarding its functionality. Your help in shedding light on this matter would be greatly appreciated.

@NCP Thanks for your time! Finally, I found the issue. Actually, I was in production mode. After updating the hook file, I ran migration every time, but it didn’t seem to take effect. After some time, I had a spark of insight: let’s restart the bench and try it once more.

Before that, I assumed in common_site_config.json where restart_supervisor_on_update is set to true, so I assumed that migrating the system would restart the supervisor. However, I realized that this setting doesn’t actually restart the supervisor. Consequently, even after migration, the Python script didn’t reload, and the code remained the same as before.

I believe this was the problem. After restarting the bench, everything is working fine now. I’ve checked the flow twice, and it seems to work like this. Please correct me if I’m wrong.