CN105989091B - JS file loading method, device and system for page display - Google Patents

JS file loading method, device and system for page display Download PDF

Info

Publication number
CN105989091B
CN105989091B CN201510075862.5A CN201510075862A CN105989091B CN 105989091 B CN105989091 B CN 105989091B CN 201510075862 A CN201510075862 A CN 201510075862A CN 105989091 B CN105989091 B CN 105989091B
Authority
CN
China
Prior art keywords
file
menu
identifier
file corresponding
user
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510075862.5A
Other languages
Chinese (zh)
Other versions
CN105989091A (en
Inventor
屈传鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201510075862.5A priority Critical patent/CN105989091B/en
Publication of CN105989091A publication Critical patent/CN105989091A/en
Application granted granted Critical
Publication of CN105989091B publication Critical patent/CN105989091B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Transfer Between Computers (AREA)

Abstract

The application discloses a JS file loading method, device and system for page display, wherein the method comprises the following steps: receiving a first URL and a user identifier sent by a client; determining menus included in a page corresponding to the first URL, and acquiring an identifier of an entrance JS file corresponding to each menu and an identifier of a service JS file corresponding to a user-defined block under each menu; and generating a second URL, adding the identification of the entrance JS file corresponding to each menu and the identification of the business JS file corresponding to the user identification custom block under each menu into the variable attribute of the second URL, sending the variable attribute to the client so as to enable the client to determine the current menu, acquiring the identification of the entrance JS file corresponding to the current menu and the identification of the business JS file corresponding to the user identification custom block under the current menu from the variable attribute of the second URL, and acquiring the JS file. The scheme saves server and network bandwidth resources; and the loading time of the JS file is shortened, so that the page display time is reduced.

Description

JS file loading method, device and system for page display
Technical Field
The application relates to the technical field of networks, in particular to a JS file loading method, device and system for page display.
Background
With the rapid development of network technology, information provided on the internet is more and more abundant, more and more users acquire information from the internet through clients, and the clients can provide information to the users through display pages. Generally, a page includes a plurality of menus, each menu includes a plurality of blocks, the web page has a corresponding entry JS (javascript) file, each menu also has a corresponding entry JS file, and each block also has a corresponding service JS file.
When a user needs to browse a certain page, a client sends an access request carrying a Uniform Resource Locator (URL) of the page to an application server; the method comprises the steps that an application server obtains a HyperText markup Language (HTML) file corresponding to a page, analyzes the identification of an entrance JS file corresponding to the page and the identification of an entrance JS file corresponding to a menu depended by the page from the HTML file, combines the analyzed identifications of the entrance JS files, puts the combined identifications into the tag attribute of a new URL, and sends the new URL to a client; after receiving the new URL, the client analyzes the identifications of all entrance JS files carried in the tag attribute of the new URL, and sends file acquisition requests carrying the identifications of the entrance JS files to the static resource server; the static resource server sends the JS entrance files to the client; the client determines a current menu selected by a user, and sends an identification acquisition request carrying the current menu and a user identification to an application server; the application server determines the identification of the service JS file corresponding to the user identification in the user-defined block under the current menu and sends the identification to the client; and the client loads the user-defined block and the service JS file corresponding to the block depending on the user-defined block under the current menu in an asynchronous loading mode.
In the method, when a user needs to browse a certain page, the entry JS files corresponding to the page and the entry JS files corresponding to all menus that the page depends on are loaded, and in fact, the user may only browse part of the menus and not browse all the menus, but the client needs to load the entry JS files corresponding to all the menus that the page depends on, and as a plurality of useless entry JS files are loaded, server and network bandwidth resources are seriously wasted; secondly, when the client loads the JS file corresponding to the user-defined block and the JS file corresponding to the block depending on the user-defined block, the asynchronous loading mode is adopted, so that the loading time of the JS file is prolonged, and the page display time is prolonged.
Disclosure of Invention
The embodiment of the application provides a JS file loading method, device and system for page display, which are used for solving the problems that server and network bandwidth resources are seriously wasted and the JS file loading time is prolonged in the prior art.
According to the embodiment of the application, a JS file loading method for page display is provided, which comprises the following steps:
receiving a first Uniform Resource Locator (URL) and a user identifier sent by a client;
determining menus included in a page corresponding to the first URL, and acquiring an identifier of an entrance JS file corresponding to each menu and an identifier of a service JS file corresponding to a user-defined block under each menu;
generate the second URL, add the sign of the entry JS file that every menu corresponds and the sign of the business JS file that user identification custom block under every menu corresponds to in the variable attribute of second URL, send for the client, so that the current menu is confirmed to the client, follow acquire in the variable attribute of second URL the sign of the entry JS file that the current menu corresponds and the user identification is in the sign of the business JS file that custom block corresponds under the current menu to acquire the JS file, the JS file includes the entry JS file that the current menu corresponds and the business JS file that custom block corresponds under the current menu.
Specifically, obtain the sign of the entry JS file that each menu corresponds and the sign of the business JS file that the user identification corresponds to the custom block under each menu specifically includes:
acquiring an identifier of an entrance JS file corresponding to each menu from a pre-stored identifier text;
and acquiring the identification of the service JS file corresponding to the user identification in the user-defined block under each menu from a user database.
According to the embodiment of the application, a JS file loading method for page display is further provided, which is applied to a client and includes:
sending a first Uniform Resource Locator (URL) and a user identifier to an application server, so that the application server determines menus included by a page corresponding to the first URL, acquires an identifier of an entrance JS file corresponding to each menu and identifiers of business JS files corresponding to user-defined blocks of the user identifier under each menu, generates a second URL, adds the identifiers of the entrance JS files corresponding to each menu and the identifiers of the business JS files corresponding to the user-defined blocks of the user identifier under each menu into the variable attribute of the second URL and sends the identifiers;
receiving the second URL;
determining a current menu, and acquiring an identifier of an entrance JS file corresponding to the current menu and an identifier of a service JS file corresponding to a user identifier custom block under the current menu from the variable attribute of the second URL;
and acquiring the JS file, wherein the JS file comprises an entrance JS file corresponding to the current menu and a service JS file corresponding to the custom block under the current menu.
Specifically, obtain the JS file, specifically include:
sending an identifier of an entrance JS file corresponding to the current menu and an identifier of a service JS file corresponding to the user identifier in the custom block under the current menu to a static resource server so that the static resource server acquires the JS file;
and receiving the JS file sent by the static resource server.
Optionally, the method further includes:
removing the duplicate of the identifier related to each menu carried in the variable attribute of the second URL, storing the duplicate identifier in a general group, and storing the identifier related to each menu after the duplicate removal in a group corresponding to the menu, wherein the identifier related to each menu comprises an identifier of an entrance JS file corresponding to each menu and an identifier of a business JS file corresponding to a user-defined block of the user identifier under each menu;
acquiring the JS file, specifically comprising:
detecting whether a service JS file corresponding to the identifier included in the general group is stored locally;
if the service JS file corresponding to the identifier included in the general group is stored locally, the identifier included in the group of the current menu is sent to a static resource server, so that the static resource server acquires and sends the JS file corresponding to the identifier included in the group of the current menu, receives the JS file sent by the static resource server, locally acquires the service JS file corresponding to the identifier included in the general group, and determines the received JS file sent by the static resource server and the locally acquired service JS file as the JS file;
if the service JS file corresponding to the identifier included in the general group is not stored locally, the identifier included in the general group and the identifier included in the group of the current menu are sent to a static resource server, so that the static resource server acquires and sends the JS file corresponding to the identifier included in the general group and the identifier included in the group of the current menu; and receiving the JS file sent by the static resource server, and determining the received JS file sent by the static resource server as the JS file.
According to the embodiment of the present application, there is further provided a JS file loading device for page display, including:
the receiving unit is used for receiving a first Uniform Resource Locator (URL) and a user identifier sent by a client;
the acquisition unit is used for determining menus included in the page corresponding to the first URL, and acquiring an identifier of an entrance JS file corresponding to each menu and an identifier of a service JS file corresponding to a user-defined block of the user identifier under each menu;
the sending unit is used for generating a second URL, adding the identification of the entrance JS file corresponding to each menu and the identification of the business JS file corresponding to the user identification under each menu custom block into the variable attribute of the second URL, sending the user identification to the client so that the client can determine the current menu, and then acquire the identification of the entrance JS file corresponding to the current menu and the identification of the business JS file corresponding to the custom block under the current menu and acquire the JS file, wherein the JS file comprises the entrance JS file corresponding to the current menu and the business JS file corresponding to the custom block under the current menu.
Specifically, the obtaining unit is specifically configured to:
acquiring an identifier of an entrance JS file corresponding to each menu from a pre-stored identifier text;
and acquiring the identification of the service JS file corresponding to the user identification in the user-defined block under each menu from a user database.
According to the embodiment of the present application, there is further provided a JS file loading device for page display, which is applied to a client, and includes:
the sending unit is used for sending a first Uniform Resource Locator (URL) and a user identifier to an application server so that the application server determines menus included by a page corresponding to the first URL, acquires an identifier of an entrance JS file corresponding to each menu and identifiers of business JS files corresponding to user-defined blocks of the user identifier under each menu, generates a second URL, adds the identifiers of the entrance JS files corresponding to each menu and the identifiers of the business JS files corresponding to the user-defined blocks of the user identifier under each menu into variable attributes of the second URL and sends the identifiers;
a receiving unit configured to receive the second URL;
the first obtaining unit is used for determining a current menu, and obtaining an identifier of an entrance JS file corresponding to the current menu and an identifier of a service JS file corresponding to a user identifier in a custom block under the current menu from the variable attribute of the second URL;
and the second acquisition unit is used for acquiring the JS file, wherein the JS file comprises an entrance JS file corresponding to the current menu and a service JS file corresponding to the custom block under the current menu.
Specifically, the second obtaining unit is specifically configured to:
sending an identifier of an entrance JS file corresponding to the current menu and an identifier of a service JS file corresponding to the user identifier in the custom block under the current menu to a static resource server so that the static resource server acquires the JS file;
and receiving the JS file sent by the static resource server.
Optionally, the receiving unit is further configured to:
removing the duplicate of the identifier related to each menu carried in the variable attribute of the second URL, storing the duplicate identifier in a general group, and storing the identifier related to each menu after the duplicate removal in a group corresponding to the menu, wherein the identifier related to each menu comprises an identifier of an entrance JS file corresponding to each menu and an identifier of a business JS file corresponding to a user-defined block of the user identifier under each menu;
the second obtaining unit is specifically configured to:
detecting whether a service JS file corresponding to the identifier included in the general group is stored locally;
if the service JS file corresponding to the identifier included in the general group is stored locally, the identifier included in the group of the current menu is sent to a static resource server, so that the static resource server acquires and sends the JS file corresponding to the identifier included in the group of the current menu, receives the JS file sent by the static resource server, locally acquires the service JS file corresponding to the identifier included in the general group, and determines the received JS file sent by the static resource server and the locally acquired service JS file as the JS file;
if the service JS file corresponding to the identifier included in the general group is not stored locally, the identifier included in the general group and the identifier included in the group of the current menu are sent to a static resource server, so that the static resource server acquires and sends the JS file corresponding to the identifier included in the general group and the identifier included in the group of the current menu; and receiving the JS file sent by the static resource server, and determining the received JS file sent by the static resource server as the JS file.
According to the embodiment of the application, a JS file loading system for page display is further provided, and includes a client and an application server, where:
the client comprises the JS file loading device for page display;
the application server comprises the JS file loading device for displaying the page.
The embodiment of the application provides a method, a device and a system for loading a JS file for page display, wherein an application server receives a first Uniform Resource Locator (URL) and a user identifier sent by a client; determining menus included in a page corresponding to the first URL, and acquiring an identifier of an entrance JS file corresponding to each menu and an identifier of a service JS file corresponding to a user-defined block under each menu; generate the second URL, add the sign of the entry JS file that every menu corresponds and the sign of the business JS file that user identification custom block under every menu corresponds to into send in the variable attribute of second URL the client, so that the current menu is confirmed to the client, follow acquire in the variable attribute of second URL the sign of the entry JS file that the current menu corresponds and the user identification is in the sign of the business JS file that custom block corresponds under the current menu to acquire the JS file, the JS file includes the entry JS file that the current menu corresponds and the business JS file that custom block corresponds under the current menu. In the scheme, when a user needs to browse a page, a first URL corresponding to the page and a user identifier can be sent to an application server together, and correspondingly, the application server adds an identifier of an entry JS file corresponding to each menu and an identifier of a service JS file corresponding to a user identifier under each menu custom block into a variable attribute of a second URL and sends the variable attribute of the second URL together to a client, so that the client can obtain the entry JS file corresponding to a current menu and the service JS file corresponding to the custom block under the current menu at one time according to the variable attribute of the second URL to finish loading of the JS files; and the JS file of the service corresponding to the custom block is loaded at the same time, and an asynchronous loading mode is not adopted any more, so that the loading time of the JS file is shortened, and the page display time is reduced.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
fig. 1 is a schematic structural diagram of a JS file loading system for page display in an embodiment of the present application;
fig. 2 is a flowchart of a JS file loading method for page display when an execution subject is an application server in the embodiment of the present application;
fig. 3 is a flowchart of a JS file loading method for page display when an execution subject is a client in the embodiment of the present application;
FIG. 4 is a diagram illustrating an application scenario in an embodiment of the present application;
fig. 5 is a flowchart of a JS file loading method for page display corresponding to fig. 1 in an embodiment of the present application;
fig. 6 is a schematic structural diagram of a JS file loading device for page display corresponding to fig. 2 in an embodiment of the present application;
fig. 7 is a schematic structural diagram of a JS file loading device for page display corresponding to fig. 3 in the embodiment of the present application.
Detailed Description
In order to make the technical problems, technical solutions and advantageous effects to be solved by the present application clearer and clearer, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
In order to solve the problems of serious waste of server and network bandwidth resources and prolongation of JS file loading time in the prior art, an embodiment of the present application provides a JS file loading method for page display, which is implemented by a JS file loading system for page display as shown in fig. 1, and the system includes an application server 1 and a client 2. The JS file loading method for page display is described below with the client and the server as the execution subjects, respectively.
When the execution subject is an application server, the flow of the JS file loading method for page display is shown in fig. 2, and includes the following steps:
s21: and receiving a first URL and a user identification sent by the client.
At present, a plurality of pages provide a user login function, a user can complete login after inputting a user identifier and a password on a certain page, the page generally comprises a plurality of menus, the user can browse the menus, the page provides a function of block customization under each menu, the user can select the customized block under each menu, so that only the customized block is displayed when the menu is browsed later, and the customized block can comprise all or part of blocks under each menu.
When the client detects that the user selects a menu or needs to display a default menu, the client sends a URL (hereinafter referred to as a first URL) and a user identifier of a page including the menu to the application server, and specifically, may send an access request carrying the first URL and the user identifier to the application server.
S22: determining the menus included in the page corresponding to the first URL, and acquiring the identification of the entrance JS file corresponding to each menu and the identification of the business JS file corresponding to the user identification in the user-defined block under each menu.
Usually, the identifier of the entry JS file corresponding to each menu is stored in the identifier text, and the user data is stored in the user database, so that the identifier of the entry JS file corresponding to each menu can be obtained from the pre-stored identifier text first, and then the identifier of the service JS file corresponding to the user-defined block of the user identifier under each menu is obtained from the user database.
The entry JS file is a file required when entering the menu, and the service JS file is a file required for realizing the service function of the block.
S23: and generating a second URL (Uniform resource locator), adding the identification of the entrance JS file corresponding to each menu and the identification of the business JS file corresponding to the user identification custom block under each menu into the variable attribute of the second URL, sending the variable attribute to the client so that the client can determine the current menu, acquiring the identification of the entrance JS file corresponding to the current menu and the identification of the business JS file corresponding to the user identification custom block under the current menu from the variable attribute of the second URL, and acquiring the JS files, wherein the JS files comprise the entrance JS file corresponding to the current menu and the business JS file corresponding to the custom block under the current menu.
Since the identification of the entry JS file corresponding to the page and the identification of the entry JS file corresponding to the menu on which the page depends are analyzed in the background technology and stored in the tag attribute of a new URL, and the client automatically loads the JS files corresponding to all the identifications in the tag attribute, in order to avoid the occurrence of the phenomenon, the dependency relationship between the page and the menu can be cancelled, the identification of the entry JS file corresponding to each menu and the identification of the business JS file corresponding to the custom block of the user identification under each menu are all added into the variable attribute of the second URL and sent to the client, and the JS files corresponding to all the identifications in the variable attribute can not be automatically added by the client, so that the client can be ensured to obtain the identification of the entry JS file corresponding to the current menu in the variable attribute and the identification of the business JS file corresponding to the custom block of the user identification under the current menu as required, and only loading the entrance JS file corresponding to the current menu and the service JS file corresponding to the custom block under the current menu.
When the identification of the entry JS file corresponding to each menu and the identification of the service JS file corresponding to the user identification custom tile under each menu are added to the variable attribute of the second URL, a third party merging tool, such as StyleCombine, may be employed.
In the scheme, when a user needs to browse a page, a first URL corresponding to the page and a user identifier can be sent to an application server together, and correspondingly, the application server adds an identifier of an entry JS file corresponding to each menu and an identifier of a service JS file corresponding to a user identifier under each menu custom block into a variable attribute of a second URL and sends the variable attribute of the second URL together to a client, so that the client can obtain the entry JS file corresponding to a current menu and the service JS file corresponding to the custom block under the current menu at one time according to the variable attribute of the second URL to finish loading of the JS files; and the JS file of the service corresponding to the custom block is loaded at the same time, and an asynchronous loading mode is not adopted any more, so that the loading time of the JS file is shortened, and the page display time is reduced.
When the execution subject is the client, the flow of the JS file loading method for page display is shown in fig. 3, and includes the following steps:
s31: and sending the first URL and the user identification to an application server so that the application server determines menus included in a page corresponding to the first URL, acquiring an identifier of an entrance JS file corresponding to each menu and an identifier of a business JS file corresponding to a user identification custom block under each menu, generating a second URL, adding the identifier of the entrance JS file corresponding to each menu and the identifier of the business JS file corresponding to the user identification custom block under each menu into the variable attribute of the second URL, and sending the variable attribute.
S32: a second URL is received.
S33: and determining the current menu, and acquiring the identification of the entrance JS file corresponding to the current menu and the identification of the business JS file corresponding to the user identification custom block under the current menu from the variable attribute of the second URL.
When a page corresponding to the first URL is displayed for the first time, the default menu is the current menu, and when a user finishes browsing one menu and selects another menu, the other menu is the current menu; and after the current menu is determined, acquiring the identification of the entrance JS file corresponding to the current menu and the identification of the service JS file corresponding to the user identification custom block under the current menu from the variable attribute of the second URL.
To illustrate by way of an example, fig. 4 is a schematic diagram of an application scenario in which a page includes five menus of home page, wholesale purchase, production purchase, sale, and application, the current menu is "production purchase", and the user identifier is "sourcing dynamic", "cull product", and "transaction, favorite, and quoted supplier" in the custom section under "production purchase", then the client may obtain the identifier of the entry JS file corresponding to "production purchase" and the identifiers of the service JS files corresponding to "sourcing dynamic", "cull product", and "transaction, favorite, and quoted supplier" from the variable attribute of the second URL.
S34: and acquiring the JS file, wherein the JS file comprises an entrance JS file corresponding to the current menu and a service JS file corresponding to the custom block under the current menu.
The client can directly acquire the JS file, and the JS file comprises an entrance JS file corresponding to the current menu and a service JS file corresponding to the custom block under the current menu, so that loading of the JS file is completed, and the custom block under the current menu of the user can be successfully displayed.
In the scheme, when a user needs to browse a page, a first URL corresponding to the page and a user identifier can be sent to an application server together, and correspondingly, the application server adds an identifier of an entry JS file corresponding to each menu and an identifier of a service JS file corresponding to a user identifier under each menu custom block into a variable attribute of a second URL and sends the variable attribute of the second URL together to a client, so that the client can obtain the entry JS file corresponding to a current menu and the service JS file corresponding to the custom block under the current menu at one time according to the variable attribute of the second URL to finish loading of the JS files; and the JS file of the service corresponding to the custom block is loaded at the same time, and an asynchronous loading mode is not adopted any more, so that the loading time of the JS file is shortened, and the page display time is reduced.
Specifically, the process of acquiring the JS file in S34 specifically includes:
sending an identification of an entrance JS file corresponding to the current menu and an identification of a business JS file corresponding to the user identification custom block under the current menu to the static resource server so that the static resource server can obtain the JS file;
and receiving the JS file sent by the static resource server.
The JS file related to the page corresponding to the first URL may be saved in the static resource server, and then the required JS file may be obtained from the static resource server.
Optionally, the JS file loading method for page display further includes:
and removing the duplicate of the identifier related to each menu carried in the variable attribute of the second URL, storing the duplicate identifiers in a general group, and storing the identifiers related to each menu after the duplicate removal in a group corresponding to the menu, wherein the identifiers related to each menu comprise the identifier of an entrance JS file corresponding to each menu and the identifier of a business JS file corresponding to a user identifier custom block under each menu.
Since there may be repeated blocks in the menu included in one page, in order to avoid the waste of the server and the network resources caused by repeated downloading of the service JS file corresponding to the repeated blocks, the duplicate removal may be performed on the identifier related to each menu carried in the variable attribute of the second URL.
For example, one page includes menus a, b, and c, where the id of the entry JS file of menu a is d, the id of the service JS file corresponding to the user-defined block under menu a is e, f, and g, the id of the entry JS file of menu b is h, the id of the service JS file corresponding to the user-defined block under menu b is e, i, and j, the id of the entry JS file of menu c is k, the id of the service JS file corresponding to the user-defined block under menu c is e, l, and m, then the id of the menu a is d, e, f, and g, the id of menu b is h, e, i, and j, the id of menu c is k, e, l, and m, and it can be seen that e is a repeated id, and can be stored in a general group, and then the id of each menu after deduplication is stored in a group corresponding to the menus, that is, the group of menu a includes d, f, and g, and, f and g, the grouping of the menu b comprises h, i and j, and the grouping of the menu c comprises k, l and m.
Correspondingly, the obtaining of the JS file in S34 specifically includes:
detecting whether a service JS file corresponding to the identifier included in the general group is stored locally;
if the service JS file corresponding to the identifier included in the general group is locally stored, the identifier included in the group of the current menu is sent to the static resource server, so that the static resource server obtains and sends the JS file corresponding to the identifier included in the group of the current menu, the JS file sent by the static resource server is received, the service JS file corresponding to the identifier included in the general group is locally obtained, and the received JS file sent by the static resource server and the service JS file locally obtained are determined as JS files;
if the service JS file corresponding to the identifier included in the general group is not stored locally, the identifier included in the general group and the identifier included in the group of the current menu are sent to the static resource server, so that the static resource server obtains and sends the JS file corresponding to the identifier included in the general group and the identifier included in the group of the current menu; and receiving the JS file sent by the static resource server, and determining the JS file sent by the static resource server as the JS file.
Based on the deduplication processing, when acquiring the JS file, whether the JS file for the service corresponding to the identifier included in the general group is locally stored or not can be checked, if so, the JS file corresponding to the identifier included in the packet of the current menu is acquired from the static resource server and sent, the JS file sent by the static resource server is received, the JS file for the service corresponding to the identifier included in the general group is acquired locally, and the received JS file sent by the static resource server and the received JS file for the service acquired locally are determined as JS files; if not, the JS file corresponding to the identifier included in the general group and the identifier included in the group of the current menu can be obtained from the static resource server, and the received JS file sent by the static resource server is determined as the JS file.
The JS file loading method for page display when the application server and the client are used as the execution subjects is described above, and the JS file loading method in the JS file loading system for page display shown in fig. 1 is described below, where the system may further include a static resource server 3, as shown in fig. 5, and the specific execution steps are as follows:
s51: the client sends the first URL and the user identification to the application server.
S52: the application server receives the first URL and the user identification sent by the client.
S53: the application server determines the menus included in the page corresponding to the first URL, obtains the identification of the entrance JS file corresponding to each menu and the identification of the business JS file corresponding to the user identification in the user-defined block under each menu, generates a second URL, adds the identification of the entrance JS file corresponding to each menu and the identification of the business JS file corresponding to the user identification in the user-defined block under each menu into the variable attribute of the second URL, and sends the variable attribute to the client.
The identification of the entry JS file corresponding to each menu can be obtained from the pre-saved identification text, and the identification of the service JS file corresponding to the user identification custom block under each menu is obtained from the user database.
S54: and the client receives the second URL, the identifier related to each menu carried in the variable attribute of the second URL is subjected to duplication elimination, the duplicated identifiers are stored in a general group, the identifier related to each menu after duplication elimination is stored in a group corresponding to the menu, and the identifier related to each menu comprises an identifier of an entrance JS file corresponding to each menu and an identifier of a business JS file corresponding to a user identifier custom block under each menu.
S55: and the client determines the current menu, and acquires the identification of the entrance JS file corresponding to the current menu and the identification of the service JS file corresponding to the user identification custom block under the current menu from the variable attribute of the second URL.
S56: the client detects whether a service JS file corresponding to the identifier included in the general group is stored locally, if yes, S57 is executed; if not, go to S60.
S57: and the client sends the identification included by the grouping of the current menu to the static resource server.
S58: and the static resource server acquires and sends the JS file corresponding to the identifier included in the group of the current menu.
S59: and the client receives the JS file sent by the static resource server and locally acquires a service JS file corresponding to the identifier included in the general group.
The received JS file sent by the static resource server and the locally acquired service JS file are the entrance JS file corresponding to the current menu and the service JS file corresponding to the custom block under the current menu, namely the JS file which needs to be loaded when page display is carried out.
S60: and the client sends the identification included by the general group and the identification included by the grouping of the current menu to the static resource server.
S61: and the static resource server acquires the identification included by the general group and the JS file corresponding to the identification included by the grouping of the current menu and sends the JS file.
S62: and the client receives the JS file sent by the static resource server.
The received JS files sent by the static resource server are the entrance JS files corresponding to the current menu and the service JS files corresponding to the custom block under the current menu, namely the JS files needing to be loaded when page display is carried out.
In the scheme, when a user needs to browse a page, a first URL corresponding to the page and a user identifier can be sent to an application server together, and correspondingly, the application server adds an identifier of an entry JS file corresponding to each menu and an identifier of a service JS file corresponding to a user identifier under each menu custom block into a variable attribute of a second URL and sends the variable attribute of the second URL together to a client, so that the client can obtain the entry JS file corresponding to a current menu and the service JS file corresponding to the custom block under the current menu at one time according to the variable attribute of the second URL to finish loading of the JS files; and the JS file of the service corresponding to the custom block is loaded at the same time, and an asynchronous loading mode is not adopted any more, so that the loading time of the JS file is shortened, and the page display time is reduced.
Based on the same inventive concept, the embodiment of the present application further provides an information providing apparatus, which corresponds to the JS file loading method for page display shown in fig. 2, can be arranged in the application server 1 in the JS file loading system for page display shown in fig. 1, and has a structure shown in fig. 6, and includes a receiving unit 61, an obtaining unit 62, and a sending unit 63. Wherein:
the receiving unit 61 is configured to receive the first URL and the user identifier sent by the client.
The obtaining unit 62 is configured to determine the menus included in the page corresponding to the first URL, and obtain an identifier of an entry JS file corresponding to each menu and an identifier of a service JS file corresponding to the user-defined block of the user identifier under each menu.
And the sending unit 63 is configured to generate a second URL, add the identifier of the entry JS file corresponding to each menu and the identifier of the service JS file corresponding to the user-defined block of the user identifier under each menu to the variable attribute of the second URL, send the identifiers to the client, so that the client determines the current menu, obtain the identifier of the entry JS file corresponding to the current menu and the identifier of the service JS file corresponding to the user-defined block of the user identifier under the current menu from the variable attribute of the second URL, and obtain the JS files, where the JS files include the entry JS file corresponding to the current menu and the service JS file corresponding to the user-defined block under the current menu.
In the scheme, when a user needs to browse a page, a first URL corresponding to the page and a user identifier can be sent to an application server together, and correspondingly, the application server adds an identifier of an entry JS file corresponding to each menu and an identifier of a service JS file corresponding to a user identifier under each menu custom block into a variable attribute of a second URL and sends the variable attribute of the second URL together to a client, so that the client can obtain the entry JS file corresponding to a current menu and the service JS file corresponding to the custom block under the current menu at one time according to the variable attribute of the second URL to finish loading of the JS files; and the JS file of the service corresponding to the custom block is loaded at the same time, and an asynchronous loading mode is not adopted any more, so that the loading time of the JS file is shortened, and the page display time is reduced.
Specifically, the obtaining unit 62 is specifically configured to:
acquiring an identifier of an entrance JS file corresponding to each menu from a pre-stored identifier text;
and acquiring the identifier of the service JS file corresponding to the user identifier in the user-defined block under each menu from the user database.
Based on the same inventive concept, the embodiment of the present application further provides an information providing apparatus, which corresponds to the JS file loading method for page display shown in fig. 3, can be provided in the client 2 in the JS file loading system for page display shown in fig. 1, and has a structure shown in fig. 7, and includes a sending unit 71, a receiving unit 72, a first obtaining unit 73, and a second obtaining unit 74. Wherein:
the sending unit 71 is configured to send the first URL and the user identifier to the application server, so that the application server determines the menus included in the page corresponding to the first URL, obtains an identifier of an entry JS file corresponding to each menu and an identifier of a service JS file corresponding to the user-defined block of the user identifier under each menu, generates a second URL, adds the identifier of the entry JS file corresponding to each menu and the identifier of the service JS file corresponding to the user-defined block of the user identifier under each menu to the variable attribute of the second URL, and sends the identifiers.
A receiving unit 72, configured to receive the second URL.
The first obtaining unit 73 is configured to determine the current menu, and obtain, from the variable attribute of the second URL, an identifier of an entry JS file corresponding to the current menu and an identifier of a service JS file corresponding to the user identifier of the custom block in the current menu.
And a second obtaining unit 74, configured to obtain the JS file, where the JS file includes an entry JS file corresponding to the current menu and a service JS file corresponding to the custom block under the current menu.
In the scheme, when a user needs to browse a page, a first URL corresponding to the page and a user identifier can be sent to an application server together, and correspondingly, the application server adds an identifier of an entry JS file corresponding to each menu and an identifier of a service JS file corresponding to a user identifier under each menu custom block into a variable attribute of a second URL and sends the variable attribute of the second URL together to a client, so that the client can obtain the entry JS file corresponding to a current menu and the service JS file corresponding to the custom block under the current menu at one time according to the variable attribute of the second URL, thereby completing loading of the JS files; and the JS file of the service corresponding to the custom block is loaded at the same time, and an asynchronous loading mode is not adopted any more, so that the loading time of the JS file is shortened, and the page display time is reduced.
Specifically, the second obtaining unit 74 is specifically configured to:
sending an identification of an entrance JS file corresponding to the current menu and an identification of a business JS file corresponding to the user identification custom block under the current menu to the static resource server so that the static resource server can obtain the JS file;
and receiving the JS file sent by the static resource server.
Optionally, the receiving unit 72 is further configured to:
and removing the duplicate of the identifier related to each menu carried in the variable attribute of the second URL, storing the duplicate identifiers in a general group, and storing the identifiers related to each menu after the duplicate removal in a group corresponding to the menu, wherein the identifiers related to each menu comprise the identifier of an entrance JS file corresponding to each menu and the identifier of a business JS file corresponding to a user identifier custom block under each menu.
Accordingly, the second obtaining unit 74 is specifically configured to:
detecting whether a service JS file corresponding to the identifier included in the general group is stored locally;
if the service JS file corresponding to the identifier included in the general group is locally stored, the identifier included in the group of the current menu is sent to the static resource server, so that the static resource server obtains and sends the JS file corresponding to the identifier included in the group of the current menu, the JS file sent by the static resource server is received, the service JS file corresponding to the identifier included in the general group is locally obtained, and the received JS file sent by the static resource server and the service JS file locally obtained are determined as JS files;
if the service JS file corresponding to the identifier included in the general group is not stored locally, the identifier included in the general group and the identifier included in the group of the current menu are sent to the static resource server, so that the static resource server obtains and sends the JS file corresponding to the identifier included in the general group and the identifier included in the group of the current menu; and receiving the JS file sent by the static resource server, and determining the JS file sent by the static resource server as the JS file.
The foregoing description shows and describes the preferred embodiments of the present application, but as aforementioned, it is to be understood that the application is not limited to the forms disclosed herein, but is not to be construed as excluding other embodiments and is capable of use in various other combinations, modifications, and environments and is capable of changes within the scope of the inventive concept as expressed herein, commensurate with the above teachings, or the skill or knowledge of the relevant art. And that modifications and variations may be effected by those skilled in the art without departing from the spirit and scope of the application, which is to be protected by the claims appended hereto.

Claims (11)

1. A JS file loading method for page display is applied to an application server and is characterized by comprising the following steps:
receiving a first Uniform Resource Locator (URL) and a user identifier sent by a client;
determining menus included in a page corresponding to the first uniform resource locator URL, and acquiring an identifier of an entrance JS file corresponding to each menu and an identifier of a service JS file corresponding to a user-defined block of the user identifier under each menu;
generate the second URL, add the sign of the entry JS file that every menu corresponds and the sign of the business JS file that user identification custom block under every menu corresponds to in the variable attribute of second URL, send for the client, so that the current menu is confirmed to the client, follow acquire in the variable attribute of second URL the sign of the entry JS file that the current menu corresponds and the user identification is in the sign of the business JS file that custom block corresponds under the current menu to acquire the JS file, the JS file includes the entry JS file that the current menu corresponds and the business JS file that custom block corresponds under the current menu.
2. The method of claim 1, wherein obtaining the identifier of the entry JS file corresponding to each menu and the identifier of the service JS file corresponding to the custom tile for the user identifier under each menu specifically includes:
acquiring an identifier of an entrance JS file corresponding to each menu from a pre-stored identifier text;
and acquiring the identification of the service JS file corresponding to the user identification in the user-defined block under each menu from a user database.
3. A JS file loading method for page display is applied to a client, and is characterized by comprising the following steps:
sending a first Uniform Resource Locator (URL) and a user identifier to an application server, so that the application server determines menus included by a page corresponding to the first Uniform Resource Locator (URL), acquires an identifier of an entrance JS file corresponding to each menu and identifiers of service JS files corresponding to user-defined blocks of the user identifier under each menu, generates a second URL, adds the identifiers of the entrance JS files corresponding to each menu and the identifiers of the service JS files corresponding to the user-defined blocks of the user identifier under each menu into variable attributes of the second URL and sends the identifiers;
receiving the second URL;
determining a current menu, and acquiring an identifier of an entrance JS file corresponding to the current menu and an identifier of a service JS file corresponding to a user identifier custom block under the current menu from the variable attribute of the second URL;
and acquiring the JS file, wherein the JS file comprises an entrance JS file corresponding to the current menu and a service JS file corresponding to the custom block under the current menu.
4. The method of claim 3, wherein obtaining the JS file specifically comprises:
sending an identifier of an entrance JS file corresponding to the current menu and an identifier of a service JS file corresponding to the user identifier in the custom block under the current menu to a static resource server so that the static resource server acquires the JS file;
and receiving the JS file sent by the static resource server.
5. The method of claim 3, further comprising:
removing the duplicate of the identifier related to each menu carried in the variable attribute of the second URL, storing the duplicate identifier in a general group, and storing the identifier related to each menu after the duplicate removal in a group corresponding to the menu, wherein the identifier related to each menu comprises an identifier of an entrance JS file corresponding to each menu and an identifier of a business JS file corresponding to a user-defined block of the user identifier under each menu;
acquiring the JS file, specifically comprising:
detecting whether a service JS file corresponding to the identifier included in the general group is stored locally;
if the service JS file corresponding to the identifier included in the general group is stored locally, the identifier included in the group of the current menu is sent to a static resource server, so that the static resource server acquires and sends the Js file corresponding to the identifier included in the group of the current menu, the JS file sent by the static resource server is received, the service JS file corresponding to the identifier included in the general group is acquired locally, and the received JS file sent by the static resource server and the service JS file acquired locally are determined as the JS files;
if the service JS file corresponding to the identifier included in the general group is not stored locally, the identifier included in the general group and the identifier included in the group of the current menu are sent to a static resource server, so that the static resource server acquires and sends the JS file corresponding to the identifier included in the general group and the identifier included in the group of the current menu; and receiving the JS file sent by the static resource server, and determining the received JS file sent by the static resource server as the JS file.
6. The utility model provides a JS file loading device for page display, which comprises:
the receiving unit is used for receiving a first Uniform Resource Locator (URL) and a user identifier sent by a client;
the acquisition unit is used for determining menus included in a page corresponding to the first uniform resource locator URL, and acquiring an identifier of an entrance JS file corresponding to each menu and an identifier of a service JS file corresponding to a user identifier custom block under each menu;
the sending unit is used for generating a second URL, adding the identification of the entrance JS file corresponding to each menu and the identification of the business JS file corresponding to the user identification under each menu custom block into the variable attribute of the second URL, sending the user identification to the client so that the client can determine the current menu, and then acquire the identification of the entrance JS file corresponding to the current menu and the identification of the business JS file corresponding to the custom block under the current menu and acquire the JS file, wherein the JS file comprises the entrance JS file corresponding to the current menu and the business JS file corresponding to the custom block under the current menu.
7. The apparatus of claim 6, wherein the obtaining unit is specifically configured to:
acquiring an identifier of an entrance JS file corresponding to each menu from a pre-stored identifier text;
and acquiring the identification of the service JS file corresponding to the user identification in the user-defined block under each menu from a user database.
8. The utility model provides a JS file loading device for page display, is applied to in the client, its characterized in that includes:
the sending unit is used for sending a first Uniform Resource Locator (URL) and a user identifier to an application server, so that the application server determines menus included by a page corresponding to the first Uniform Resource Locator (URL), acquires an identifier of an entrance JS file corresponding to each menu and identifiers of business JS files corresponding to user-defined blocks of the user identifier under each menu, generates a second URL, adds the identifiers of the entrance JS files corresponding to each menu and the identifiers of the business JS files corresponding to the user-defined blocks of the user identifier under each menu into the variable attribute of the second URL and sends the identifiers;
a receiving unit configured to receive the second URL;
the first obtaining unit is used for determining a current menu, and obtaining an identifier of an entrance JS file corresponding to the current menu and an identifier of a service JS file corresponding to a user identifier in a custom block under the current menu from the variable attribute of the second URL;
and the second acquisition unit is used for acquiring the JS file, wherein the JS file comprises an entrance JS file corresponding to the current menu and a service JS file corresponding to the custom block under the current menu.
9. The apparatus of claim 8, wherein the second obtaining unit is specifically configured to:
sending an identifier of an entrance JS file corresponding to the current menu and an identifier of a service JS file corresponding to the user identifier in the custom block under the current menu to a static resource server so that the static resource server acquires the JS file;
and receiving the JS file sent by the static resource server.
10. The apparatus of claim 8, wherein the receiving unit is further configured to:
removing the duplicate of the identifier related to each menu carried in the variable attribute of the second URL, storing the duplicate identifier in a general group, and storing the identifier related to each menu after the duplicate removal in a group corresponding to the menu, wherein the identifier related to each menu comprises an identifier of an entrance JS file corresponding to each menu and an identifier of a business JS file corresponding to a user-defined block of the user identifier under each menu;
the second obtaining unit is specifically configured to:
detecting whether a service JS file corresponding to the identifier included in the general group is stored locally;
if the service JS file corresponding to the identifier included in the general group is stored locally, the identifier included in the group of the current menu is sent to a static resource server, so that the static resource server acquires and sends the JS file corresponding to the identifier included in the group of the current menu, receives the JS file sent by the static resource server, locally acquires the service JS file corresponding to the identifier included in the general group, and determines the received JS file sent by the static resource server and the locally acquired service JS file as the JS file;
if the service JS file corresponding to the identifier included in the general group is not stored locally, the identifier included in the general group and the identifier included in the group of the current menu are sent to a static resource server, so that the static resource server acquires and sends the JS file corresponding to the identifier included in the general group and the identifier included in the group of the current menu; and receiving the JS file sent by the static resource server, and determining the received JS file sent by the static resource server as the JS file.
11. A JS file loading system for page display is characterized by comprising a client and an application server, wherein:
the client comprises the JS file loading device for page display of claim 6 or 7;
the application server comprises a JS file loading device for page display as claimed in any of claims 8 to 10.
CN201510075862.5A 2015-02-12 2015-02-12 JS file loading method, device and system for page display Active CN105989091B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510075862.5A CN105989091B (en) 2015-02-12 2015-02-12 JS file loading method, device and system for page display

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510075862.5A CN105989091B (en) 2015-02-12 2015-02-12 JS file loading method, device and system for page display

Publications (2)

Publication Number Publication Date
CN105989091A CN105989091A (en) 2016-10-05
CN105989091B true CN105989091B (en) 2019-12-24

Family

ID=57042168

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510075862.5A Active CN105989091B (en) 2015-02-12 2015-02-12 JS file loading method, device and system for page display

Country Status (1)

Country Link
CN (1) CN105989091B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106648810A (en) * 2017-01-24 2017-05-10 东软集团股份有限公司 Application program resource obtaining method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101645090A (en) * 2009-08-04 2010-02-10 成都市华为赛门铁克科技有限公司 Page display method, server and network system
CN102799640A (en) * 2012-06-27 2012-11-28 用友软件股份有限公司 Page loading device and page loading method
CN103500194A (en) * 2013-09-17 2014-01-08 北京奇虎科技有限公司 Method, device and browser for loading webpage
CN103530160A (en) * 2013-10-21 2014-01-22 迈普通信技术股份有限公司 Page loading method and device
CN104283865A (en) * 2013-07-12 2015-01-14 贝壳网际(北京)安全技术有限公司 Download processing method and device, server and client device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
IL149977A0 (en) * 2002-06-02 2009-02-11 Internet Forex Products Inc Generated applications

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101645090A (en) * 2009-08-04 2010-02-10 成都市华为赛门铁克科技有限公司 Page display method, server and network system
CN102799640A (en) * 2012-06-27 2012-11-28 用友软件股份有限公司 Page loading device and page loading method
CN104283865A (en) * 2013-07-12 2015-01-14 贝壳网际(北京)安全技术有限公司 Download processing method and device, server and client device
CN103500194A (en) * 2013-09-17 2014-01-08 北京奇虎科技有限公司 Method, device and browser for loading webpage
CN103530160A (en) * 2013-10-21 2014-01-22 迈普通信技术股份有限公司 Page loading method and device

Also Published As

Publication number Publication date
CN105989091A (en) 2016-10-05

Similar Documents

Publication Publication Date Title
CN109308255B (en) Method and device for A/B test experiment
US11038975B2 (en) Information pushing method and device
CN107256232B (en) Information recommendation method and device
US20150193821A1 (en) Information processing apparatus, information processing method, and information processing program
US20130046623A1 (en) Method For Providing a Recommendation, Recommender System, and Recommender Computer Program Product
CN110198328B (en) Client identification method and device, computer equipment and storage medium
US11244153B2 (en) Method and apparatus for processing information
CN106302445A (en) For the method and apparatus processing request
CN108369709A (en) Network-based ad data service delay reduces
CN104243273A (en) Method and device for displaying information on instant messaging client and information display system
US20140244784A1 (en) Website Impersonation System and Method
CN105488205A (en) Page generation method and page generation apparatus
CN110866040B (en) User portrait generation method, device and system
US20240103889A1 (en) Systems and methods for rendering and retaining application data associated with a plurality of applications within a group-based communication system
US9357020B2 (en) Information source selection system, information source selection method, and program
CN107632971B (en) Method and device for generating multidimensional report
CN110958462A (en) Live broadcast activity page display method and device, storage medium and live broadcast system
JP2016062489A (en) Information processing device, terminal device, information processing method, and information processing program
CN107918617B (en) Data query method and device
CN108600780A (en) Method for pushed information
CN113761565B (en) Data desensitization method and device
CN105989091B (en) JS file loading method, device and system for page display
CN108011936A (en) Method and apparatus for pushed information
KR102023999B1 (en) Method and apparatus for generating web pages
CN109218339B (en) Request processing method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant