Webform client script or js

I have this script I want to run on a webform:

frappe.web_form.on('form_fieldname', () => {
    frappe.call({
        method: "path.to.my.method",
        args: {
            "doctype": "Doctype Name",
            "field": "dt_fieldname" }, 
        callback: function(r) {
            //some script to run 
        }
    });
});

I know this script runs because it runs when I put it in the Client Script section of the webform.

But it doesn’t run when I put it in the js file of the webform.
*Note: the frappe.web_form.after_load = () => {} runs well from the js file.

From the docs (Customizing Web Forms) I read example to use the event handler API:

frappe.web_form.on('amount', (field, value) => {
}

Where (field, value) is the handler.

My questions:

  • Should I write the handler in my script?
  • If so, what is it?
  • Why in the Client Script it works and not in the js file?

Thank you