Summary of the invention
The embodiment of the present application provide a kind of show for the page JS file loading method, Apparatus and system, existing in order to solveSerious waste server and network bandwidth resources present in technology, and the problem extending the time that JS file loads.
According to the embodiment of the present application, it is provided that a kind of JS file loading method shown for the page, including:
Receive the first uniform resource position mark URL and ID that client sends;
Determine the menu that a described page corresponding for URL includes, obtain the mark of entrance JS file corresponding to each menu withAnd the mark of business JS file corresponding to described ID self-defined block under each menu;
Generate the 2nd URL, by the mark of entrance JS file corresponding for each menu and described ID under each menuThe mark of the business JS file that self-defined block is corresponding is added in the variable's attribute of described 2nd URL, is sent to described clientEnd, so that described client determines the current set of menu, obtains described the current set of menu corresponding from the variable's attribute of described 2nd URLThe mark of entrance JS file and business JS file corresponding to described ID self-defined block under described the current set of menuMark, and obtain JS file, described JS file include entrance JS file that described the current set of menu is corresponding and described currentlyThe business JS file that under menu, self-defined block is corresponding.
Concrete, the mark and the described ID that obtain entrance JS file corresponding to each menu are made by oneself under each menuThe mark of the business JS file that justice block is corresponding, specifically includes:
The mark of entrance JS file corresponding to each menu is obtained from the mark text pre-saved;
The mark of business JS file corresponding to described ID self-defined block under each menu is obtained from customer data baseKnow.
According to the embodiment of the present application, also provide for a kind of JS file loading method shown for the page, be applied in client,Including:
The first uniform resource position mark URL and ID is sent, so that described application server determines institute to application serverState the menu that a page corresponding for URL includes, obtain the mark of entrance JS file corresponding to each menu and described userMark mark of the business JS file that self-defined block is corresponding under each menu, generates the 2nd URL, and each menu is correspondingThe mark of entrance JS file and the mark of business JS file corresponding to described ID self-defined block under each menuKnow and add in the variable's attribute of described 2nd URL and send;
Receive described 2nd URL;
Determine the current set of menu, from the variable's attribute of described 2nd URL, obtain entrance JS file corresponding to described the current set of menuMark and the mark of business JS file corresponding to described ID self-defined block under described the current set of menu;
Obtaining JS file, described JS file includes under entrance JS file that described the current set of menu is corresponding and described the current set of menuThe business JS file that self-defined block is corresponding.
Concrete, obtain JS file, specifically include:
The mark of entrance JS file corresponding to described the current set of menu and described ID is sent in institute to static resource serverState the mark of business JS file corresponding to self-defined block under the current set of menu, so that described static resource server obtains described JSFile;
Receive the described JS file that described static resource server sends.
Optionally, also include:
The mark that each menu carried in the variable's attribute of described 2nd URL is relevant is carried out duplicate removal, and the mark that will repeatIt is saved in common group, the mark that each menu after duplicate removal is relevant is saved in the packet of corresponding menu, each menu phaseThe mark closed includes mark and described ID self-defined district under each menu of the entrance JS file that each menu is correspondingThe mark of the business JS file that block is corresponding;
Obtain JS file, specifically include:
Whether detection this locality preserves the business JS file of the mark correspondence that described common group includes;
If the local business JS file preserving the mark correspondence that described common group includes, then send described to static resource serverThe mark that the packet of the current set of menu includes, so that described static resource server obtains the mark that the packet of described the current set of menu includesKnow corresponding JS file cocurrent to send, receive the JS file that described static resource server sends, and obtain from this locality described logicalWith the business JS file of the mark correspondence that group includes, by the JS file of the described static resource server transmission of reception with from thisThe business JS file that ground obtains is defined as described JS file;
If this locality does not preserves the business JS file of the mark correspondence that described common group includes, then send institute to static resource serverState the mark that the packet of mark that common group includes and described the current set of menu includes, so that described static resource server obtains instituteState the corresponding JS file cocurrent that identifies that the mark that common group includes includes with the packet of described the current set of menu to send;Receive described quietThe JS file that state Resource Server sends, is defined as described JS by the JS file that the described static resource server received sendsFile.
According to the embodiment of the present application, also provide for a kind of JS file charger shown for the page, including:
Receive unit, for receiving the first uniform resource position mark URL and the ID that client sends;
Acquiring unit, for determining the menu that a described page corresponding for URL includes, obtains the entrance that each menu is correspondingThe mark of the business JS file that the mark of JS file and described ID self-defined block under each menu is corresponding;
Transmitting element, for generating the 2nd URL, by mark and the described user mark of entrance JS file corresponding for each menuKnow during under each menu, the mark of the business JS file that self-defined block is corresponding adds the variable's attribute of described 2nd URL to,It is sent to described client, so that described client determines the current set of menu, from the variable's attribute of described 2nd URL, obtains instituteMark and the described ID self-defined block under described the current set of menu of stating entrance JS file corresponding to the current set of menu are correspondingThe mark of business JS file, and obtain JS file, described JS file includes the entrance JS literary composition that described the current set of menu is correspondingThe business JS file that under part and described the current set of menu, self-defined block is corresponding.
Concrete, described acquiring unit, specifically for:
The mark of entrance JS file corresponding to each menu is obtained from the mark text pre-saved;
The mark of business JS file corresponding to described ID self-defined block under each menu is obtained from customer data baseKnow.
According to the embodiment of the present application, also provide for a kind of JS file charger shown for the page, be applied in client,Including:
Transmitting element, for sending the first uniform resource position mark URL and ID to application server, answers so that describedDetermine, with server, the menu that a described page corresponding for URL includes, obtain the mark of entrance JS file corresponding to each menuKnow and the mark of business JS file corresponding to described ID self-defined block under each menu, generate the 2nd URL,By mark and the described ID industry that self-defined block is corresponding under each menu of entrance JS file corresponding for each menuThe mark of business JS file is added in the variable's attribute of described 2nd URL and sends;
Receive unit, be used for receiving described 2nd URL;
First acquiring unit, is used for determining the current set of menu, obtains described the current set of menu from the variable's attribute of described 2nd URLThe mark of corresponding entrance JS file and described ID business JS that self-defined block is corresponding under described the current set of menuThe mark of file;
Second acquisition unit, is used for obtaining JS file, and described JS file includes the entrance JS file that described the current set of menu is correspondingAnd the business JS file that under described the current set of menu, self-defined block is corresponding.
Concrete, described second acquisition unit, specifically for:
The mark of entrance JS file corresponding to described the current set of menu and described ID is sent in institute to static resource serverState the mark of business JS file corresponding to self-defined block under the current set of menu, so that described static resource server obtains described JSFile;
Receive the described JS file that described static resource server sends.
Optionally, described reception unit, it is additionally operable to:
The mark that each menu carried in the variable's attribute of described 2nd URL is relevant is carried out duplicate removal, and the mark that will repeatIt is saved in common group, the mark that each menu after duplicate removal is relevant is saved in the packet of corresponding menu, each menu phaseThe mark closed includes mark and described ID self-defined district under each menu of the entrance JS file that each menu is correspondingThe mark of the business JS file that block is corresponding;
Described second acquisition unit, specifically for:
Whether detection this locality preserves the business JS file of the mark correspondence that described common group includes;
If the local business JS file preserving the mark correspondence that described common group includes, then send described to static resource serverThe mark that the packet of the current set of menu includes, so that described static resource server obtains the mark that the packet of described the current set of menu includesKnow corresponding JS file cocurrent to send, receive the JS file that described static resource server sends, and obtain from this locality described logicalWith the business JS file of the mark correspondence that group includes, by the JS file of the described static resource server transmission of reception with from thisThe business JS file that ground obtains is defined as described JS file;
If this locality does not preserves the business JS file of the mark correspondence that described common group includes, then send institute to static resource serverState the mark that the packet of mark that common group includes and described the current set of menu includes, so that described static resource server obtains instituteState the corresponding JS file cocurrent that identifies that the mark that common group includes includes with the packet of described the current set of menu to send;Receive described quietThe JS file that state Resource Server sends, is defined as described JS by the JS file that the described static resource server received sendsFile.
According to the embodiment of the present application, also provide for a kind of JS file loading system shown for the page, including client and applicationServer, wherein:
Described client includes the above-mentioned JS file charger shown for the page;
Described application server includes the above-mentioned JS file charger shown for the page.
The embodiment of the present application provide a kind of show for the page JS file loading method, Apparatus and system, application server connectsReceive the first uniform resource position mark URL and ID that client sends;Determine that a described page corresponding for URL includesMenu, obtain mark and described ID self-defined district under each menu of entrance JS file corresponding to each menuThe mark of the business JS file that block is corresponding;Generate the 2nd URL, by mark and the institute of entrance JS file corresponding for each menuThe mark stating business JS file corresponding to ID self-defined block under each menu adds the variable of described 2nd URL toAttribute is sent to described client, so that described client determines the current set of menu, from the variable's attribute of described 2nd URLObtain mark and described ID self-defined district under described the current set of menu of entrance JS file corresponding to described the current set of menuThe mark of the business JS file that block is corresponding, and obtain JS file, described JS file includes the entrance that described the current set of menu is correspondingThe business JS file that under JS file and described the current set of menu, self-defined block is corresponding.In the program, user needs browsing pagesTime, a URL corresponding for this page and ID can be sent jointly to application server, correspondingly application serverBy mark and ID business JS that self-defined block is corresponding under each menu of entrance JS file corresponding for each menuThe mark of file is added in the variable's attribute of the 2nd URL and is sent jointly to client, thus client can be according to the 2nd URLVariable's attribute disposably obtain the business that under entrance JS file corresponding to the current set of menu and the current set of menu, self-defined block is correspondingJS file, completes JS file and loads, self-defined under the entrance JS file corresponding due to only the current set of menu and the current set of menuThe business JS file that block is corresponding is loaded, and does not load unnecessary entrance JS file, thus saves server and Netowrk tapeWide resource;And the business JS file that self-defined block is corresponding is loaded, and no longer uses the mode of Asynchronous loading, and this is just simultaneouslyThe time that JS file loads can be shortened, thus reduce the time that the page shows.
Detailed description of the invention
In order to make technical problems to be solved in this application, technical scheme and beneficial effect clearer, clear, below in conjunction withDrawings and Examples, are further elaborated to the application.Only should be appreciated that specific embodiment described hereinIn order to explain the application, it is not used to limit the application.
In order to solve serious waste server and network bandwidth resources present in prior art, and extend what JS file loadedThe problem of time, the embodiment of the present application provides a kind of JS file loading method shown for the page, by as shown in Figure 1The JS file loading system shown for the page realizes, and this system includes application server 1 and client 2.Separately below withClient and server is the JS file loading method that executive agent introduction shows for the page.
When executive agent is application server, the flow process of the JS file loading method shown for the page is as in figure 2 it is shown, bagInclude following steps:
S21: receive URL and the ID that client sends.
At present, a lot of pages provide user's login feature, after user inputs ID and password on certain page,Completing to log in, the usual page includes a lot of menu, user may browse through these menus, owing to the page provides at each menuUnder carry out the self-defining function of block, user can select the self-defined block under each menu, thus browses menu afterwardsTime only show that self-defined block, self-defined block can include all or part of block under each menu.
When client detects that user selects a menu or when needing to show default menu, then will include the page of this menuThe URL (the hereinafter referred to as the oneth URL) in face and ID are sent to application server, and concrete can send out to application serverSend and carry a URL and the access request of ID.
S22: determine the menu that a page corresponding for URL includes, obtains the mark of entrance JS file corresponding to each menuAnd the mark of business JS file corresponding to ID self-defined block under each menu.
The mark of the entrance JS file that usual each menu is corresponding is saved in mark text, and user data is saved in user dataIn storehouse, therefore, it can the first-selected mark obtaining entrance JS file corresponding to each menu from the mark text pre-saved,The mark of business JS file corresponding to ID self-defined block under each menu is obtained again from customer data base.
Wherein, the file that entrance JS file needs when being to enter menu, business JS file is that the business function realizing block needsThe file wanted.
S23: generate the 2nd URL, by the mark of entrance JS file corresponding for each menu and ID under each menuThe mark of the business JS file that self-defined block is corresponding is added in the variable's attribute of the 2nd URL, is sent to client, so thatClient determines the current set of menu, obtain from the variable's attribute of the 2nd URL the mark of entrance JS file corresponding to the current set of menu withAnd the mark of business JS file corresponding to ID self-defined block under the current set of menu, and obtain JS file, JS fileThe business JS file that under the entrance JS file corresponding including the current set of menu and the current set of menu, self-defined block is corresponding.
Corresponding the entering of menu relied on due to the mark and the page that parse entrance JS file corresponding to the page in the introductionThe mark of mouth JS file all can be saved in the tag attributes of a new URL, and client can load in tag attributes automaticallyThe JS file that all marks are corresponding, in order to avoid the generation of this phenomenon, can cancel the dependence of the page and menu, will be everyThe mark of the entrance JS file that individual menu is corresponding and ID business JS that self-defined block is corresponding under each menu literary compositionThe mark of part is all added in the variable's attribute of the 2nd URL, and is sent to client, owing to client will not be added automaticallyThe JS file of all mark correspondences in variable's attribute, such that it is able to guarantee that client obtains working as in variable's attribute as requiredThe mark of the entrance JS file that front menu is corresponding and ID business JS that self-defined block is corresponding under the current set of menu literary compositionThe mark of part, thus only load the business that under entrance JS file corresponding to the current set of menu and the current set of menu, self-defined block is correspondingJS file.
Mark and the ID industry that self-defined block is corresponding under each menu at entrance JS file corresponding to each menuWhen the mark of business JS file is added in the variable's attribute of the 2nd URL, third party can be used to merge instrument, such asStyleCombine etc..
In the program, when user needs browsing pages, a URL corresponding for this page can be sent together with IDTo application server, correspondingly application server by the mark of entrance JS file corresponding for each menu and ID oftenUnder individual menu, the mark of the business JS file that self-defined block is corresponding sends jointly to visitor in adding the variable's attribute of the 2nd URL toFamily end, thus client can according to the variable's attribute of the 2nd URL disposably obtain entrance JS file corresponding to the current set of menu withAnd the business JS file that under the current set of menu, self-defined block is corresponding, complete JS file and load, owing to only the current set of menu is correspondingEntrance JS file and the current set of menu under business JS file corresponding to self-defined block be loaded, do not load unnecessary enteringMouth JS file, thus save server and network bandwidth resources;And the business JS file quilt simultaneously that self-defined block is correspondingLoading, no longer use the mode of Asynchronous loading, this will shorten the time that JS file loads, thus reduce that the page shows timeBetween.
When executive agent is client, the flow process of the JS file loading method shown for the page as it is shown on figure 3, include asLower step:
S31: send URL and an ID to application server, so that application server determines a page corresponding for URLThe menu that face includes, the mark and the ID that obtain entrance JS file corresponding to each menu are self-defined under each menuThe mark of the business JS file that block is corresponding, generates the 2nd URL, by the mark of entrance JS file corresponding for each menu andThe mark of the business JS file that ID self-defined block under each menu is corresponding is added in the variable's attribute of the 2nd URLAnd send.
S32: receive the 2nd URL.
S33: determine the current set of menu, obtains the mark of entrance JS file corresponding to the current set of menu from the variable's attribute of the 2nd URLKnow and the mark of business JS file corresponding to ID self-defined block under the current set of menu.
When oneth page corresponding for URL is to show first, the menu of acquiescence is the current set of menu, when user has browsed a menuWhen selecting another menu, another menu is the current set of menu;After determining the current set of menu, from the variable's attribute of the 2nd URLObtain mark and the ID business that self-defined block is corresponding under the current set of menu of entrance JS file corresponding to the current set of menuThe mark of JS file.
Illustrate with an example below, be illustrated in figure 4 the schematic diagram of an application scenarios, in this application scenarios,The page includes homepage, wholesale stocks up, production procurement, sells, applies five menus, and the current set of menu is " production procurement ", usesMark self-defined block under " production procurement " in family for " sourcing dynamically ", " selected product " and " is concluded the business, is collected, to meThe supplier offered ", then, client can obtain " production procurement " corresponding entering from the variable's attribute of the 2nd URLThe mark of mouth JS file and " sourcing dynamically ", " selected product " and " supplier concluding the business, collecting, offered to me "The mark of corresponding business JS file.
S34: obtain JS file, JS file includes self-defined district under entrance JS file that the current set of menu is corresponding and the current set of menuThe business JS file that block is corresponding.
Client can directly obtain JS file, and this JS file includes entrance JS file that the current set of menu is corresponding and current dishThe business JS file that under list, self-defined block is corresponding, thus complete JS file and load, can successfully show user's the current set of menuUnder self-defined block.
In the program, when user needs browsing pages, a URL corresponding for this page can be sent together with IDTo application server, correspondingly application server by the mark of entrance JS file corresponding for each menu and ID oftenUnder individual menu, the mark of the business JS file that self-defined block is corresponding sends jointly to visitor in adding the variable's attribute of the 2nd URL toFamily end, thus client can according to the variable's attribute of the 2nd URL disposably obtain entrance JS file corresponding to the current set of menu withAnd the business JS file that under the current set of menu, self-defined block is corresponding, complete JS file and load, owing to only the current set of menu is correspondingEntrance JS file and the current set of menu under business JS file corresponding to self-defined block be loaded, do not load unnecessary enteringMouth JS file, thus save server and network bandwidth resources;And the business JS file quilt simultaneously that self-defined block is correspondingLoading, no longer use the mode of Asynchronous loading, this will shorten the time that JS file loads, thus reduce that the page shows timeBetween.
Concrete, above-mentioned S34 obtains the process of JS file, specifically includes:
The mark of entrance JS file corresponding to the current set of menu and ID is sent under the current set of menu to static resource serverThe mark of the business JS file that self-defined block is corresponding, so that static resource server obtains JS file;
Receive the JS file that static resource server sends.
The JS file that oneth page corresponding for URL is relevant can be saved in static resource server, then from static resourceServer obtains the JS file of needs, certainly can also use a lot of preserving type, illustrate the most one by one.
Optionally, the above-mentioned JS file loading method shown for the page also includes:
The mark that each menu carried in the variable's attribute of the 2nd URL is relevant is carried out duplicate removal, and the mark repeated is preservedIn common group, the mark that each menu after duplicate removal is relevant being saved in the packet of corresponding menu, each menu is correlated withMark includes that the mark of the entrance JS file that each menu is corresponding and ID self-defined block under each menu are correspondingThe mark of business JS file.
Owing to the menu that a page includes there may be the block of repetition, in order to avoid business JS corresponding to repeating blockFile carries out repeated downloads, thus causes the waste of server and Internet resources, therefore can be to the variable's attribute of the 2nd URLIn the relevant mark of each menu of carrying carry out duplicate removal.
Such as, a page includes menu a, b, c, the entrance JS file of menu a be designated d, user is at menu aUnder business JS file corresponding to self-defined block be designated e, f, g, the entrance JS file of menu b be designated h, useThe business JS file that family self-defined block under menu b is corresponding be designated e, i, j, the mark of the entrance JS file of menu cKnow for k, the business JS file that user's self-defined block under menu c is corresponding be designated e, l, m, then menu a phaseClose is designated d, e, f and g, and what menu b was relevant is designated h, e, i and j, what menu c was relevant be designated k, e,L and m, it is seen that e is the mark repeated, and can be saved in common group, the mark then each menu after duplicate removal being correlated withBe saved in the packet of corresponding menu, i.e. the packet of menu a includes that d, f and g, the packet of menu b include h, i and j,The packet of menu c includes k, l and m.
Correspondingly, the acquisition JS file in above-mentioned S34, specifically include:
Whether detection this locality preserves the business JS file of the mark correspondence that common group includes;
If the local business JS file preserving the mark correspondence that common group includes, then send the current set of menu to static resource serverThe mark that includes of packet so that static resource server obtains JS file corresponding to mark that the packet of the current set of menu includes alsoSend, receive the JS file that static resource server sends, and identify corresponding business JS from what this locality acquisition common group includedFile, the JS file sent by the static resource server of reception and the business JS file obtained from this locality are defined as JS file;
If this locality does not preserves the business JS file of the mark correspondence that common group includes, then send common group to static resource serverIncluding mark and the mark that includes of the packet of the current set of menu so that static resource server obtain mark that common group includes andThe JS file cocurrent of the mark correspondence that the packet of the current set of menu includes send;Receive the JS file that static resource server sends,The JS file that the static resource server of reception sends is defined as JS file.
Process based on above-mentioned duplicate removal, when obtaining JS file, can first check for whether this locality preserves the mark that common group includesCorresponding business JS file, if so, obtains, from static resource server, the JS identifying correspondence that the packet of the current set of menu includesFile cocurrent send, and receives the JS file that static resource server sends, and obtain mark that common group includes from this locality correspondingBusiness JS file, the JS file sent by the static resource server of reception and the business JS file obtained from this locality are defined asJS file;If it is not, the mark that the packet of the mark that can include from static resource server acquisition common group and the current set of menu includesKnow corresponding JS file, the JS file that the static resource server of reception sends is defined as JS file.
Below describe respectively with application server and client for the JS file loading side shown for page during executive agentMethod, is described below such as the JS file loading method in the JS file loading system that the page shows of Fig. 1, this systemStatic resource server 3 can also be included, as it is shown in figure 5, it is as follows specifically to perform step:
S51: client sends URL and an ID to application server.
S52: application server receives URL and the ID that client sends.
S53: application server determines the menu that a page corresponding for URL includes, obtains the entrance JS that each menu is correspondingThe mark of the business JS file that the mark of file and ID self-defined block under each menu is corresponding, generates secondURL, by corresponding to mark and ID self-defined block under each menu of entrance JS file corresponding for each menuThe mark of business JS file is added in the variable's attribute of the 2nd URL, is sent to client.
The mark of entrance JS file corresponding to each menu can be obtained, from customer data base from the mark text pre-savedThe mark of the business JS file that middle acquisition ID self-defined block under each menu is corresponding.
S54: client receives the 2nd URL, the mark that each menu carried is relevant is carried out in the variable's attribute of the 2nd URLDuplicate removal, and the mark of repetition is saved in common group, the mark that each menu after duplicate removal is relevant is saved in corresponding menuPacket in, the mark that each menu is relevant includes that the mark of the entrance JS file that each menu is corresponding and ID are oftenThe mark of the business JS file that self-defined block is corresponding under individual menu.
S55: client determines the current set of menu, obtains the entrance JS literary composition that the current set of menu is corresponding from the variable's attribute of the 2nd URLThe mark of the business JS file that the mark of part and ID self-defined block under the current set of menu is corresponding.
Whether S56: client detection this locality preserves the business JS file of the mark correspondence that common group includes, if so, performs S57;If it is not, perform S60.
S57: client sends, to static resource server, the mark that the packet of the current set of menu includes.
The JS file cocurrent that S58: static resource server obtains mark that the packet of the current set of menu includes corresponding send.
S59: client receives the JS file that static resource server sends, and obtain the mark that includes of common group from this locality rightThe business JS file answered.
The JS file that the static resource server received sends and the business JS file from this locality acquisition, it is simply that the current set of menu pairThe business JS file that under the entrance JS file answered and the current set of menu, self-defined block is corresponding, i.e. carries out needing to add during page displayThe JS file carried.
S60: client sends, to static resource server, the mark that the packet of the mark that includes of common group and the current set of menu includes.
What the mark that S61: static resource server acquisition common group includes included with the packet of the current set of menu identifies corresponding JSFile cocurrent send.
S62: client receives the JS file that static resource server sends.
The JS file that the static resource server received sends is exactly entrance JS file corresponding to the current set of menu and the current set of menuUnder business JS file corresponding to self-defined block, i.e. carry out the JS file needing to load during page display.
In the program, when user needs browsing pages, a URL corresponding for this page can be sent together with IDTo application server, correspondingly application server by the mark of entrance JS file corresponding for each menu and ID oftenUnder individual menu, the mark of the business JS file that self-defined block is corresponding sends jointly to visitor in adding the variable's attribute of the 2nd URL toFamily end, thus client can according to the variable's attribute of the 2nd URL disposably obtain entrance JS file corresponding to the current set of menu withAnd the business JS file that under the current set of menu, self-defined block is corresponding, complete JS file and load, owing to only the current set of menu is correspondingEntrance JS file and the current set of menu under business JS file corresponding to self-defined block be loaded, do not load unnecessary enteringMouth JS file, thus save server and network bandwidth resources;And the business JS file quilt simultaneously that self-defined block is correspondingLoading, no longer use the mode of Asynchronous loading, this will shorten the time that JS file loads, thus reduce that the page shows timeBetween.
Based on same inventive concept, the embodiment of the present application also provides for a kind of information provider unit, this device and the use shown in Fig. 2The JS file loading method shown in the page is corresponding, can be arranged on the JS file shown for the page as shown in Figure 1In application server 1 in loading system, structure is as shown in 6 figures, including receiving unit 61, acquiring unit 62 and sending singleUnit 63.Wherein:
Receive unit 61, for receiving URL and the ID that client sends.
Acquiring unit 62, for determining the menu that a page corresponding for URL includes, obtains the entrance JS that each menu is correspondingThe mark of the business JS file that the mark of file and ID self-defined block under each menu is corresponding.
Transmitting element 63, for generating the 2nd URL, by mark and the ID of entrance JS file corresponding for each menuDuring under each menu, the mark of the business JS file that self-defined block is corresponding adds the variable's attribute of the 2nd URL to, it is sent toClient, so that client determines the current set of menu, obtains the entrance JS that the current set of menu is corresponding from the variable's attribute of the 2nd URLThe mark of the business JS file that the mark of file and ID self-defined block under the current set of menu is corresponding, and obtain JSFile, JS file includes business JS that under entrance JS file that the current set of menu is corresponding and the current set of menu, self-defined block is correspondingFile.
In the program, when user needs browsing pages, a URL corresponding for this page can be sent together with IDTo application server, correspondingly application server by the mark of entrance JS file corresponding for each menu and ID oftenUnder individual menu, the mark of the business JS file that self-defined block is corresponding sends jointly to visitor in adding the variable's attribute of the 2nd URL toFamily end, thus client can according to the variable's attribute of the 2nd URL disposably obtain entrance JS file corresponding to the current set of menu withAnd the business JS file that under the current set of menu, self-defined block is corresponding, complete JS file and load, owing to only the current set of menu is correspondingEntrance JS file and the current set of menu under business JS file corresponding to self-defined block be loaded, do not load unnecessary enteringMouth JS file, thus save server and network bandwidth resources;And the business JS file quilt simultaneously that self-defined block is correspondingLoading, no longer use the mode of Asynchronous loading, this will shorten the time that JS file loads, thus reduce that the page shows timeBetween.
Concrete, above-mentioned acquiring unit 62, specifically for:
The mark of entrance JS file corresponding to each menu is obtained from the mark text pre-saved;
The mark of business JS file corresponding to ID self-defined block under each menu is obtained from customer data base.
Based on same inventive concept, the embodiment of the present application also provides for a kind of information provider unit, this device and the use shown in Fig. 3The JS file loading method shown in the page is corresponding, can be arranged on the JS file shown for the page as shown in Figure 1In client 2 in loading system, structure, as shown in 7 figures, including transmitting element 71, receives unit the 72, first acquisition listUnit 73 and second acquisition unit 74.Wherein:
Transmitting element 71, for sending URL and an ID to application server, so that application server determines firstThe menu that the page corresponding for URL includes, obtains the mark of entrance JS file corresponding to each menu and ID eachThe mark of the business JS file that self-defined block is corresponding under menu, generates the 2nd URL, by entrance JS literary composition corresponding for each menuThe mark of the business JS file that the mark of part and ID self-defined block under each menu is corresponding adds the 2nd URL toVariable's attribute in and send.
Receive unit 72, for receiving the 2nd URL.
First acquiring unit 73, is used for determining the current set of menu, obtains the current set of menu corresponding from the variable's attribute of the 2nd URLThe mark of the business JS file that the mark of entrance JS file and ID self-defined block under the current set of menu is corresponding.
Second acquisition unit 74, is used for obtaining JS file, and JS file includes entrance JS file that the current set of menu is corresponding and works asThe business JS file that under front menu, self-defined block is corresponding.
In the program, when user needs browsing pages, a URL corresponding for this page can be sent together with IDTo application server, correspondingly application server by the mark of entrance JS file corresponding for each menu and ID oftenUnder individual menu, the mark of the business JS file that self-defined block is corresponding sends jointly to visitor in adding the variable's attribute of the 2nd URL toFamily end, thus client can according to the variable's attribute of the 2nd URL disposably obtain entrance JS file corresponding to the current set of menu withAnd the business JS file that under the current set of menu, self-defined block is corresponding, thus complete JS file and load, due to only the current set of menuThe business JS file that under corresponding entrance JS file and the current set of menu, self-defined block is corresponding is loaded, and it is unnecessary not loadEntrance JS file, thus save server and network bandwidth resources;And the business JS file that self-defined block is corresponding is sameTime be loaded, no longer use the mode of Asynchronous loading, this will shorten the time that JS file loads, thus reduces the page and showsTime.
Concrete, above-mentioned second acquisition unit 74, specifically for:
The mark of entrance JS file corresponding to the current set of menu and ID is sent under the current set of menu to static resource serverThe mark of the business JS file that self-defined block is corresponding, so that static resource server obtains JS file;
Receive the JS file that static resource server sends.
Optionally, above-mentioned reception unit 72, it is additionally operable to:
The mark that each menu carried in the variable's attribute of the 2nd URL is relevant is carried out duplicate removal, and the mark repeated is preservedIn common group, the mark that each menu after duplicate removal is relevant being saved in the packet of corresponding menu, each menu is correlated withMark includes that the mark of the entrance JS file that each menu is corresponding and ID self-defined block under each menu are correspondingThe mark of business JS file.
Correspondingly, above-mentioned second acquisition unit 74, specifically for:
Whether detection this locality preserves the business JS file of the mark correspondence that common group includes;
If the local business JS file preserving the mark correspondence that common group includes, then send the current set of menu to static resource serverThe mark that includes of packet so that static resource server obtains JS file corresponding to mark that the packet of the current set of menu includes alsoSend, receive the JS file that static resource server sends, and identify corresponding business JS from what this locality acquisition common group includedFile, the JS file sent by the static resource server of reception and the business JS file obtained from this locality are defined as JS file;
If this locality does not preserves the business JS file of the mark correspondence that common group includes, then send common group to static resource serverIncluding mark and the mark that includes of the packet of the current set of menu so that static resource server obtain mark that common group includes andThe JS file cocurrent of the mark correspondence that the packet of the current set of menu includes send;Receive the JS file that static resource server sends,The JS file that the static resource server of reception sends is defined as JS file.
Described above illustrate and describes the preferred embodiment of the application, but as previously mentioned, it should be understood that the application not limits toIn form disclosed herein, be not to be taken as the eliminating to other embodiments, and can be used for other combinations various, amendment andEnvironment, and can be changed by above-mentioned teaching or the technology of association area or knowledge in invention contemplated scope described hereinDynamic.And the change that those skilled in the art are carried out and change are without departing from spirit and scope, the most all should be appended by the applicationIn scope of the claims.