To ensure optimal performance at runtime, the JavaScript engine prepares the global execution context when the script is first deployed. This one-time initialization involves scanning the code to identify all variable and function declarations and executing any script code that is not enclosed within a function. While this upfront process may add a slight delay, it prevents the engine from needing to perform these operations during the first trigger, leading to a faster and more efficient script execution from the start.