Scripts are incrementally compiled at runtime to generate executable code. The incremental compilation generates executable code corresponding to a basic block of the script. The executable code for a basic block of script is generated for a set of types of variables of the basic block resulting from execution of the script in response to a request. The generated executable code is stored and executed for subsequent requests if these requests result in the same types of variables for the basic block. The incremental compilation of the script is performed in a lazy fashion, such that executable code is not generated for combinations of types of variables of the script code that are not obtained from requests received at runtime. The script may dynamically generate portions of a web page that is returned in response to a request for execution of the script.