主权项 |
1. A method of reprioritizing execution of a script, comprising:
receiving a script that is intended to be sent to and executed by a web browser, wherein the script includes a plurality of component functions; and generating, using at least one processor, a modified script on a server to be sent to and executed by the web browser, comprising:
selecting one or more of the plurality of component functions that will not be initially loaded upon execution of the modified script by the web browser; andfor each of the selected component functions:encapsulating the component function with a wrapper component function, wherein the wrapper component function includes codes that assign a body of the component function to a string variable such that the body of the component function is embedded in the modified script, and wherein the wrapper component function further includes codes that evaluate the string variable and execute the string variable as code in response to the wrapper component function being first called, thereby delaying loading of the body of the component function until the wrapper component function is first called; and transmitting the modified script from the server to the web browser, wherein the modified script is executed in the web browser. |