5-2. JavaScript functions

JavaScript function can be used to extend functionality for Visualforce page made with SkyVisualEditor. Make a common function in the Page Script to be able to call it from custom buttons, links and input fields. You can create functions for each action independently. If you write raw JavaScript not inside of a function, it will run as the Visualforce page loads. You can also include external JavaScript files and invoke methods defined within.

To run JavaScript when the screen is shown, there is no need to use a function.