Specification
BACKGROUND Background and Relevant Art
[0001] Computer systems and related technology affect many aspects of society. Indeed, the computer system's ability to process information has transformed the way we live and work. Computer systems now commonly perform a host of tasks (e.g., word processing, scheduling, accoimting, etc.) that prior to the advent of the computer system were performed manually. More recently, computer systems have been coupled to one another and to other electronic devices to form both wired and wireless computer networks over which the computer systems and other electronic devices can transfer electronic data. Accordingly, the performance of many computing tasks are distributed across a number of different computer systems and/or a number of different computing components. [0002] One common form of network based communication is exchanging electronic messages on the Worldwide Web ("AVWW"). Content on the Worldwide Web is typically accessed in a client/server model. A "Web browser" of a client computer system sends a request to access content that is provided by a "Web Server" of a server computer system (e.g., by entering a Uniform Resource Locator ("URL") into the Web browser). If the user of the Web browser is authorized to access the content, the Web server typically provides the content to the Web browser. In a Web environment, content and requests for content, are frequently transported using Hypertext Transfer Protocol ("HTTP"). Web-based content can be provided in HyperText Markup Language ("HTML") pages, style sheets, images, scripts, etc.
[0003] For example, scripts can be used to perform more complex operations than otherwise allowable using only HTML directives. Generally, scripts are executable code that can be executed at a Web server to add content to a page or can be sent down to a Web browser for execution at the Web browser to add content to a Web page. Scripts can be developed in a scripting (programming) language, such as, for example, JavaSript, VBScript, ASP, PHP, Perl, or ASP .Net. A web server can maintain pages can include both server-side and cHent-side scripts. Server-side scripts can be used to obtain data accessible to a Web server for inclusion in a Web page. Client side scripts are useful for acquiring and presenting data that may be unique to a client machine, such as, for example, a local time and date. However, more complex client side scripts, such as, for example, that request data or additional scripts from the Web sei-ver or other Web servers, are also possible. [0004] When a Web server receives a Web browser request for a Web page that includes server-side script, the Web server passes the server-side script off to an appropriate script
engine. The script engine processes the script and returns corresponding HTML directives representative of the server-side scripts functionality. The corresponding HTML directives are then injected into a Web page for return to the Web browser (along with any client-side scripts).
(00051 For example, if a server-side script is configured to query and return 10 database rows, the script engine retums the 10 database rows in a HTML format to the Web server. The Web server then injects the HTML representing the 10 database rows into any other HTML directives and client-side scriipts in the Web page. After all server-side scripts are processed, the resulting HTML from processing the server-side scripts, other HTML, and any client-side scripts are sent back to the Web browser.
[0006] Client-side scripts can be embedded in a Web page or can be included in a separate file. When a client-side smpt is included in an external file, a Web page can include a script reference (e.g., ) referencing the script. Client-side scripts and script references can be included in-line in a Web page that is sent to a Web browser. Thus, as the Web browser processes the Web page it can encounter embedded client-side scripts as well as script references to client-side scripts.
[0007] Upon encountering an emibedded script, the Web browser can refer out an appropriate script engine to process the script. Upon encountering a client-side script reference, the Web browser can load the referenced script (e.g., when a copy of the script is already cached) to the script engine for processing or it can request the script from the Web server. The Web server can then return the script to the Web browser and the Web browser can load (and potentially also cache) \he script to the script engine for processing. [0008] Web browsers typically assume that any scripts encountered later in a Web depend on scripts encountered earlier in a V/eb page. Thus, Web browsers typically load scripts one after another in the order the scripts are encountered within the Web page. However in many Web pages, subsequently emcountered scripts do not depend on any previously encountered scripts. Thus, unfortunately, and especially for Web pages with large numbers of client side scripts, one after another loading is relatively inefficient. [0009] Further, when developing a Web page, a developer may choose to include previously developed client-side scripts to utilize client side functionality. To some extent the developer may assume that the previously client-side scripts function as intended. Alternately, the developer may lack the time, desire, or expertise to thoroughly test any previously developed client-side scripts. Nonetheless, one or more client-side scripts may
fail to load or run when the Web peige is deployed. Unfortunately, typical Web browsers (and script engines therein) provide little, if any, useful context, for example, indicating the circumstances of the client-side script failure, back to the Web page developer. Thus, the Web page developer can be required to debug the Web page based on an incomplete record of information related to client-side script failures. BRIEF SUMMARY
[0010] The present invention extends to methods, systems, and computer program products for dynamically loading scripts. A Web browser receives a Web page from a Web server in response to a request for the Web page firom the Web browser. The Web page includes a reference to a script loader. The script loader is configured to, upon execution, create a data structure for queuing other script references. The script loader also configured to, upon an indication fi-om the Web browser, dynamically load scripts referenced in the Web page in accordance with script loading rules to override the default script loading behavior of the Web browser.
[0011] The Web browser executes the script loader. The script loader creates a data structure for queuing script references. The Web browser processes the Web page to queue any script references included in the Web page in the data structure. The script loader populates the queue with script the references included the Web page. The Web browser detects that no further script references are included in the Web page subsequent to queuing any script references included in the Web page.
[0012] The Web browser indicatives to the script loader that no further script references are included in the Web page. The script loader receives the indication fi-om the Web browser that no further script references are included in the specified Web page. The script loader causes scripts referenced by tlie queued script references to load in accordance with script loading rules to override the default script loading behavior of the Web browser. The Web browser includes any relevant script results in a rendering of the Web page. [0013] This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter. [0014] Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the invention. The features and advantages of the invention may be realized and obtained by means of the instruments and combinations particularly pointed
out in the appended claims. These and other features of the present invention will become
more fully apparent from the following description and appended claims, or may be learned
by the practice of the invention as set forth hereinafter.
BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to describe the manner in which the above-recited and other advantages
and features of the invention can be obtained, a more particular description of the invention
briefly described above will be rendered by reference to specific embodiments thereof
which are illustrated in the appended drawings. Understanding that these drawings depict
only typical embodiments of the invention and are not therefore to be considered to be
limiting of its scope, the invention will be described and explained with additional
specificity and detail through the use of the accompanying drawings in which:
[0016] Figure 1 illustrates an example computer architecture that facilitates dynamically
loading scripts.
[00171 Figure 2 illustrates a flow chart of an example method for dynamically loading
scripts.
DETAILED DESCRIPTION
[0018] The present invention extends to methods, systems, and computer program
products for dynamically loading scripts. A Web browser receives a Web page fi^om a Web
server in response to a request for the Web page fiom the Web browser. The Web page
includes a reference to a script loader. The script loader is configured to, upon execution,
create a data structure for queuing other script references. The script loader also configured
to, upon an indication fi-om the Web browser, dynamically load scripts referenced in the
Web page in accordance with script loading rules to override the default script loading
behavior of the Web browser.
[0019] The Web browser executes the script loader. The script loader creates a data
structure for queuing script references. The Web browser processes the Web page to queue
any script references included in the Web page in the data structure. The script loader
populates the queue with script the references included the Web page. The Web browser
detects that no fiirther script references are included in the Web page subsequent to queuing
any script references included in the Web page.
[0020] The Web browser indicatives to the script loader that no further script references
are included in the Web page. The script loader receives the indication fi-om the Web
browser that no fiirther script references are included in the specified Web page. The script
loader causing scripts referenced by the queued script references to load in accordance with
script loading rules to override the default script loading behavior of the Web browser. The Web browser includes any relevant script results in a rendering of the Web page. [0021] Embodiments of the present invention may comprise a special purpose or general-purpose computer including computer hardware, as discussed in greater detail below. Embodiments within the scope of the present invention also include computer-readable media for carrying or having computer-executable instructions or data structures stored thereon. Such computer-readable media can be any available media that can be accessed by a general purpose or special pxirpose computer. By way of example, and not limitation, computer-readable media can comprise physical (or recordable type) computer-readable storage media, such as, RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store desired program code means in the form of computer-executable instructions or data structures and which can be accessed by a general purpose or special purpose computer.
[0022] In this description and in tlie following claims, a "network" is defined as one or more data links that enable the trajisport of electronic data between computer systems and/or modules. When information is transferred or provided over a network or another communications connection (either hardwired, wireless, or a combination of hardwired or wireless) to a computer, the computer properly views the connection as a computer-readable medium. Thus, by way of example, and not limitation, computer-readable media can also comprise a network or data links which can be used to carry or store desired program code means in the form of computer-executable instructions or data structures and which can be accessed by a general purpose or special purpose computer.
[0023] Computer-executable instructions comprise, for example, instructions and data which cause a general purpose computer, special purpose computer, or special purpose processing device to perform a certain function or group of functions. The computer executable instructions may be, for example, binaries, intermediate format instructions such as assembly language, or even source code. Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the described features or acts described above. Rather, the described features and acts are disclosed as example forms of implementing the claims.
[0024] Those skilled in the art will appreciate that the invention may be practiced in network computing environments with many types of computer system configurations.
including, personal computers, desktop computers, laptop computers, message processors, hand-held devices, multi-processor systems, microprocessor-based or programmable consumer electronics, network PCs, minicomputers, mainframe computers, mobile telephones, PDAs, pagers, and the like. The invention may also be practiced in distributed system environments where local and remote computer systems, which are linked (either by hardwired data links, wireless data links, or by a combination of hardwired and wireless data links) through a network, both perform tasks. In a distributed system environment, program modules may be located in both local and remote memory storage devices. [0025] Figure 1 illustrates an example computer architecture 100 that facilitates dynamically loading scripts. As depicted, computer architecture 100 includes Web browser 101, Web server 102, and network 103. Web browser 101 and Web server 102 can be connected to network 103, such as, for example, a Local Area Network ("LAN"), a Wide Area Network ("WAN"), or even the Internet. Thus, the components of Web browser 101 and Web server 102 can receive data fi-om and send data to other components connected to network 103. Accordingly, these components can create message related data and exchange message related data (e.g., Internet Protocol ("IP") datagrams and other higher layer protocols that utilize IP datagrams, such as. Transmission Control Protocol ("TCP"), Hypertext Transfer Protocol ("HTTP"), Simple Mail Transfer Protocol ("SMTP"), etc.) over the network. For example, components can exchange HTTP requests and responses and Simple Object Access Protocol ("SOyVP") envelopes containing Web service related data. [0026] Generally, Web browser 101 is configured to request (e.g., via an HTTP message to a specified URL) and render Web-based content from Web servers, such as, for example, Web server 104, accessible via network 103. Web-based content can include text data, image data, audio/video data, executable code (e.g., scripts), etc.
[0027] Generally, Web server 102 is configured to receive requests for Web-based content (e.g., an HTTP message to a specified URL) and return requested Web-based content back to a requesting Web browser. When Web server 102 receives a request, it can identify a server-side page that corresponds to the request (e.g., dispatching the request to an appropriate process based on a URL contained in the request). Web server 106 can then load the identified server-side page.
[0028] When the server-side page includes server-side script references, Web server 106 can send the referenced server-side scripts (e.g., ASP .Net instructions) to a server-side script processor for processing. The script processor processes the server-side scripts and returns any corresponding results back to Web server 102. Web server 102 can then include
the results (potentially after additional formatting), along with other content and any client-side script references, in a Web page. Web server 102 can then return the Web page to the requesting Web browser.
[0029] Thus, for example, it may be that Web browser 101 sends requests 111 (an HTTP GET) to Web server 101 (by utilizing an appropriate URL for Web server 102). Web server 102 can process request 111 and generate/obtain corresponding content (static or dynamically accessed through server-side scripts). The corresponding content and any client-side script references can be returned to Web browser 101 in Web page 112 (e.g., contained in an HTTP message). Cli [0056] A script loader is created and registered for the Web application, such as, for example:
Sys.Application.set_scriptLoader( new Sys.ScriptLoader()); //
this.loader.addallScriptsLoaded (
this. allScriptsLoadedDelegate);
[0057] Script references, including references, inline scripts, and handlers, are queued into the script loader. As previously described scripts can be loaded form a variety of different locations. Thus, scripts can be loaded from custom libraries, such as, for example:
Sypplication.queueScriptReference('/ CustomScript.js');
Sys.Application.queueScriptReference(("Sys.Application.add_init(
$create(Custom.UI.Control, {}, {}, {},$get('f))
);
Sys.Application.initializeO; [0058] The registered script load can then be instructed to load script references it has queued, such as, for example:
Sys.Application.get_scriptLoader().set_scriptLoadTimeOut(n)
Sys.Application.getscriptLoader().loadScripts(); [0059] The script loader can indicate to the Web application when all scripts have been loaded.
[0060] In another embodiment, a script loader reference is returned to a Web browser in an asynchronous HTTP POST to a Web application. In this other embodiment, a script load may already have been created and a request manager hooked into an event on the script loaded. Thus registration can occur, such as, for example: Sys.Application, get scriptLoader(). add_allScriptsLoaded(PR>/I._allScriptsLoadedDelegate); [0061] Script references can then be queued with the internal script loader. This includes script references, inline scripts, and any handlers. Thus, scripts can be loaded from custom libraries, such as, for example:
Sys.Application.queueScriptReference('/ CustomScript.js');
Sys.Application.queueScriptReference( ("Sys.Application.add_init (
$create(Custom.UI.Control, {}, {}, {}, $get('f))
);
[0062] The registered script loader is instructed to load it's script references, such as, for example:
Sys.Application.get scriptLoader().loadScripts(); [0063] In either embodiment as well as other previously described embodiments, a page or component developer is able to define the behavior of loading scripts at a Web browser through APIs and declarative syntax of a script loader. The script manager then generates output that uses a client-side script processor.
[0064] Additional script related fimctionality can also be included in a script loader. For example, a script loader can be configured to write any script loading errors to a log file. Script loading errors can include: timeouts, dependency errors, resource errors, etc. Relevant contextual information about a script loading error can also be written to the log file when a script loading error occurs. A log file can be stored at a location accessible to a page or component developer. For example, upon detecting script loading errors at Web browser 101, script loader 108 can store log 157 to a network location within network 103. A developer can access log 157 from the network location to assist in testing and/or debugging script loader 108 as well aij other scripts.
[0065] The present invention may be embodied in other specific forms without departing from its spirit or essential characteristics. The described embodiments are to be considered in all respects only as illustrative imd not restrictive. The scope of the invention is, therefore, indicated by the appended claims rather than by the foregoing description. All
changes which come within the meaning and range of equivalency of the claims are to be embraced within their scope.
1/We Claim:
1. At a computer system connected to a network, the computer system including a Web browser configured to render Web pages at the computer system, a method for dynamically loading scripts at the Web browser, the method comprising
an act of receiving a Web page from a Web server, the Web page sent to the Web browser in response to a request for the Web page from the Web browser, the Web page including a reference to a script loader, the script loader configured to, upon execution, create a data structure for queuing other script references, the script loader also configured to, upon an indication from the Web browser, dynamically load scripts referenced in the Web page in accordance with script loading rules to override the default script loading behavior of the Web browser;
an act of executing the script loader to create a data structure for queuing script references
an act of processing the Web page to queue any script references included in the Web page in the data structure;
an act of detecting that no further script references are included in the Web page subsequent to queuing any script references included in the Web page in the data structvu-e;
an act of indicating to the script loader that no further script references are included in the Web page so as to cause the script loader to dynamically load scripts corresponding to the queued script references in accordance with the script loading rules to override the default script loading behavior of the Web browser; and
an act of including any relevant script results in a rendering of the Web page.
2. The method as recited in claim, 1 fiirther comprising:
an act of sending an HTTP GET to the Web server prior to receiving the Web page fi"om the Web server.
3. The method as recited in claim, 1 further comprising:
an act of sending an asynchronous HTTP POST to the Web server.
4. The method as recited in claim 1, wherein the act of receive a Web page from a Web server comprising an act of receiving a Web page that includes a script loader reference at the top of the Web page.
5. The method as recited in claim 1, wherein the act of indicating to the script loader that no further script references are included in the Web page so as to cause the script loader to dynamically load scripts comprises an act of indicating to the script loader that no further script references are included in the V/eb page so as to cause the script loader to load scripts in an order different than the order the scripts were encountered in the Web page.
6. The method as recited in claim 1, wherein the act of indicating to the script loader that no further script references are included in the Web page so as to cause the script loader to dynamically load scripts comprises an act of indicating to the script loader that no further script references are included in the Web page so as to cause the script loader to load a plurality of scripts in parallel.
7. The method as recited in claim 1, wherein the act of indicating to the script loader that no further script references are included in the Web page so as to cause the script loader to dynamically load scripts comprises an act of indicating to the script loader that no further script references are included in the Web page so as to cause the script loader to load scripts in a manner that limits the number of requests to any given domain.
8. The method as recited in claim 1, wherein the act of indicating to the script loader that no further script references are included in the Web page so as to cause the script loader to dynamically load scripts comprises an act of indicating to the script loader that no flirther script references are included in the Web page so as to cause the script loader to load scripts in a manner that overrides the default loading behavior of the Web browser.
9. At a computer system connected to a network, the computer system including a Web browser configured to render Web pages at the computer system and a script loader configured to dynamically load scripts referenced in a Web page to override the default script loading behavior of the Web browser, the method comprising
an act of creating a queue configured to store script references;
an act populating the queue with script references included a specified Web page;
an act of receiving an indication from the Web browser that no further script references are included in the specified Web page; and
an act of causing scripts referenced by the queued script references to load in accordance with script loading rules to override the default script loading behavior of the Web browser.
10. The method as recited in claim 9, further comprising:
an act of enumerating the script references in the queue prior to causing the scripts to be loaded so as to build up a list of script references.
11. The method as recited in claim 10, further comprising:
an act of identifying scripts that correspond to script references contained in the list of script references; and
an act of determining if any of the identified scripts are related to one another.
12. The method as recited in claim 10, further comprising:
an act of identifying that at least one script is dependent on at least one other script.
13. The method as recited in claim 10, further comprising:
an act of identifying scripts that include cross-domain requests.
14. The method as recited in claim 9, wherein the act of causing scripts to load in accordance with script loading rules comprises an act of to loading scripts in an order different than the order the scripts were encountered in the Web page.
15. The method as recited in claim 9, wherein the act of causing scripts to load in accordance with script loading rules comprises an act of to loading a plurality of scripts in parallel.
16. The method as recited in claim 9, wherein the act of causing scripts to load in accordance with script loading rules comprises an act of to loading scripts in a manner that limits the number of concurrent requests to any given domain.
17. The method as recited in claim 9, wherein the act of causing scripts to load in accordance with script loading rules comprises an act of to loading scripts in a manner that overrides the sequential loading behavior of the Web browser.
18. The method as recited in claim 9, wherein the act of causing scripts to load in accordance with script loading rules comprises an act of to loading scripts based on the characteristics of the referenced scripts and the relationships between the referenced scripts.
19. A computer system, the computer system comprising:
one or more processors;
system memory;
one or more computer-readable media having stored thereon computer-executable instructions representing a Web browser that, when executed at one of the processors, cause the Web browser to be configured to:
receive a Web page from a Web server, the Web page sent to the Web browser in response to a request for the Web page fi-om the Web browser, the Web page including a reference to computer-executable instructions representing a script loader, the script loader configured to, upon execution, create a data structure for queuing other script references, the script loader also configured to, upon an indication fi-om the Web browser, dynamically load scripts referenced in the Web page in accordance with script loading rules to override the default script loading behavior of the Web browser;
executing the computer-executable instructions of the script loader to create a data structure for queuing script references
process the Web page to queue any script references included in the Web page in the data structure;
detect that no ilirther script references are included in the Web page subsequent to queuing any script references included in the Web page in the data structure;
indicate to the script loader that no further script references are included in the Web page so as to cause the script loader to dynamically load scripts corresponding to the queued script references in accordance with the
script loading rules to override the default script loading behavior of the Web browser; and
upon execution of the computer-executable instructions representing the script loader, storing executable-instructions representing the script loader into system memory that, when executed at one of the processors, cause the script loader to be configured to:
create a queue configured to store script references;
populate the queue with script references included a specified Web page;
receive an indication fi"om the Web browser that no further script references are included in the specified Web page; and
cause scripts referenced by the queued script references to load in accordance with script loading rules to override the default script loading behavior of the Web browser.
20. The computer system as recited in claim 19, wherein scripts are loaded in accordance with script loading rules to override the default sequential script loading behavior of the Web browser based on the characteristics of the referenced scripts and the relationships between the referenced scripts.