Form Designer: How to ensure custom client-side JavaScript code is executed at runtime only

To ensure that your custom client-side JavaScript code is executed in runtime mode only, enclose your JavaScript code with the following IF block:

if (typeof $selectedObject === "undefined") {
 // Place your code here 
}