I was under the impression that javascript was client side only and executed from the local browser of the user visiting the website.
However recently I have been digging into what appears to be a server side javascript executor in Forms.
If you write
console.log('test');
then this will log to the browser each time your javascript is executed on the browser side. From this perspective everything looks normal.
However if you write
document.getElementByClassName('cf-formwrap')[0].appendChild(someObject);
this will append something to the form, for example a text message.
If you submit the form, and then look at it, you will see that the object was appended once when the form was opened, and then again by some other phantom execution. In other words, your javascript code ran one extra time!
If you log to the console AND append a message to the form. You will find only 1 log to the console, but 2 appended objects. In other words, whatever phantom executed your code an extra time, was not executing in the internet browser.
If you put this code in, at the start of your javascript, it prevents the extra server side execution from running.
//Block javascript from running server side if ($('[name=IsLocked]').val() == 'True') return;