Adding JS to a my add-on custom field


I am working in a custom field that I am adding to an add-on. I have been following this guide:

The js should only load in the edit screen. I have written this in the edit.vm of my custom field:

<script type ="text/javascript">

But it is not working in Jira 7.13 when editing the field inline (by clicking the edit icon in the view screen). If I explore the html I can see that there is nothing where the js should be. But if I open the edit issue screen the script loads works. It is not present in the html but I think it loads separatedly.

My question is what is the sanctioned and correct way to add custom js to my new custom field?

Normal way with which you load JS files into .vm templates is through webResourceManager. So normally you would define your web-resource in the atlassian-plugin.xml and then tell the manager to load it while rendering the vm file.

    <web-resource key="web-resource-name" name="abcd">
        <transformation extension="js">
            <transformer key="jsI18n"/>
        <resource type="download" name="mycustomscript.js" location="/js/mycustomscript.js"/>

In the .vm file <head>:

HOWEVER, I am not sure how it works with the customfield templates, it might not work at all.
What exactly are you trying to achieve? The Velocity can do a lot of things and you can even access Java classes and methods from the template, which gives you some maneuvering space.