CN113065083A - Page processing method and device, electronic equipment and storage medium - Google Patents

Page processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113065083A
CN113065083A CN202110223983.5A CN202110223983A CN113065083A CN 113065083 A CN113065083 A CN 113065083A CN 202110223983 A CN202110223983 A CN 202110223983A CN 113065083 A CN113065083 A CN 113065083A
Authority
CN
China
Prior art keywords
resource
page
text
current page
identifier
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.)
Pending
Application number
CN202110223983.5A
Other languages
Chinese (zh)
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.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co 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 Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202110223983.5A priority Critical patent/CN113065083A/en
Publication of CN113065083A publication Critical patent/CN113065083A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Abstract

The disclosure relates to a page processing method, a page processing device, an electronic device and a storage medium, wherein the method comprises the following steps: monitoring a starting processing event aiming at a current page; when an event for starting processing is monitored, determining a text resource identifier which is depended by a current page; storing the text resource corresponding to the text resource identifier in a compiling resource table; acquiring a text resource matched with the text resource identifier from the compiling resource table, wherein the text resource comprises a multimedia resource identifier corresponding to the current page; searching each multimedia resource identifier in a compiling resource table in the text resource, and if the multimedia resource identifier is searched in the text resource, determining that the multimedia resource corresponding to the multimedia resource identifier is a target resource which is depended on by the current page; and declaring the target resource which is depended by the current page as a preloading attribute in the entry file of the current page. The method and the device are beneficial to improving the network resource utilization rate and the page preloading efficiency in the page preloading process.

Description

Page processing method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a page processing method and apparatus, an electronic device, and a storage medium.
Background
In a browser page, a network resource expected to be used may be declared as a preload, so that the browser will load at idle time without affecting the loading of the current page.
In the front-end engineering constructed based on the webpack of the code compiling tool, plug-in html-webpack-plugin is constructed to automatically declare resources to be preloaded by using plug-in auxiliary pages. However, in the related art, it is impossible to state that only resources such as pictures and videos that are determined to be used by each page are preloaded, and states that resources that are not possible to be used are not preloaded, so that waste of network resources occurs in the process of preloading the page, and the utilization rate of the network resources and the preloading efficiency are reduced.
Disclosure of Invention
The disclosure provides a page processing method, a page processing device, an electronic device and a storage medium, which are used for at least solving the problems of low network resource utilization rate and low preloading efficiency in a page preloading process in the related art. The technical scheme of the disclosure is as follows:
according to a first aspect of the embodiments of the present disclosure, there is provided a page processing method, including:
monitoring a starting processing event aiming at a current page;
when the starting processing event is monitored, determining a text resource identifier which is depended by the current page; the text resource corresponding to the text resource identifier is stored in a compiling resource table;
acquiring a text resource matched with the text resource identifier from the compiling resource table; the text resource matched with the text resource identifier comprises a multimedia resource identifier corresponding to the current page;
searching each multimedia resource identifier in the compiling resource table in the text resource, and if the multimedia resource identifier is searched in the text resource, determining that the multimedia resource corresponding to the multimedia resource identifier is a target resource which is depended on by the current page;
and declaring the target resource which is depended by the current page as a preloading attribute in the entry file of the current page.
In an exemplary embodiment, the determining the text resource identifier on which the current page depends includes:
determining a data object in a page construction tool, wherein the page construction tool is used for constructing an entry file of the current page;
acquiring a resource code block from the data object;
extracting a script file identifier and a stacking style identifier which are depended by the current page from the resource code block to obtain a text resource identifier set depended by the current page; the text resource identifier in the text resource identifier set comprises the script file identifier and the stack style identifier.
In an exemplary embodiment, the compiled resource table uses a resource identifier as a key, and the resource content corresponding to the resource identifier is recorded with the resource content depended on by all pages in the application corresponding to the current page and the resource identifier corresponding to the resource content in a form of a value; the resource content comprises a text resource and a multimedia resource, and the resource identifier comprises a text resource identifier corresponding to the text resource and a multimedia resource identifier corresponding to the multimedia resource;
the obtaining of the text resource matched with the text resource identifier from the compiled resource table includes:
traversing the text resource identifiers in the text resource identifier set;
for each traversed text resource identifier, determining a target value matched with the key in the compiling resource table by taking the text resource identifier as the key;
and acquiring the resource content corresponding to the target value to obtain the text resource matched with the text resource identifier.
In an exemplary embodiment, the declaring, in the entry file of the current page, that the target resource on which the current page depends is a preloaded attribute includes:
generating a link label according to the target resource depended by the current page; the link label comprises a first attribute and a second attribute, wherein the first attribute indicates preloading, and the second attribute indicates a target resource on which the current page depends;
and inserting the link label into a head node of an entry file corresponding to the target page.
In an exemplary embodiment, before declaring, in the entry file of the current page, that the target resource on which the current page depends is a preloaded attribute, the method further includes:
monitoring a link label change event aiming at the entry file; the link label changing event is used for triggering the change of the link label in the head node of the entry file;
and when the link label change event is monitored, the step of declaring the target resource depended by the current page as the pre-loading attribute in the entry file of the current page is executed.
In an exemplary embodiment, the listening for a start processing event for a current page includes:
and monitoring a starting processing event aiming at the current page through a page processing front hook function in the page construction tool.
According to a second aspect of the embodiments of the present disclosure, there is provided a page processing apparatus including:
a first listening unit configured to perform listening for a start processing event for a target page;
a text resource identification determining unit configured to determine a text resource identification on which the current page depends when the start processing event is monitored; the text resource corresponding to the text resource identifier is stored in a compiling resource table;
a text resource obtaining unit configured to perform obtaining of a text resource matching the text resource identifier from the compiled resource table; the text resource matched with the text resource identifier comprises a multimedia resource identifier corresponding to the current page;
a page dependency resource determining unit, configured to perform searching for each multimedia resource identifier in the compiled resource table in the text resource, and if the multimedia resource identifier is searched for in the text resource, determine that the multimedia resource corresponding to the multimedia resource identifier is a target resource on which the current page depends;
and the declaration unit is configured to declare the target resource depended by the current page as the preloading attribute in the entry file of the current page.
In an exemplary embodiment, the text resource identifier determining unit includes:
a data object determination unit configured to perform determining a data object in a page construction tool, the page construction tool being used for constructing an entry file of the current page;
a resource code block acquisition unit configured to perform acquisition of a resource code block from the data object;
an extracting unit, configured to extract the script file identifier and the stack style identifier that the current page depends on from the resource code block, to obtain a text resource identifier set that the current page depends on; the text resource identifier in the text resource identifier set comprises the script file identifier and the stack style identifier.
In an exemplary embodiment, the compiled resource table uses a resource identifier as a key, and the resource content corresponding to the resource identifier is recorded with the resource content depended on by all pages in the application corresponding to the current page and the resource identifier corresponding to the resource content in a form of a value; the resource content comprises a text resource and a multimedia resource, and the resource identifier comprises a text resource identifier corresponding to the text resource and a multimedia resource identifier corresponding to the multimedia resource;
the text resource acquiring unit comprises:
a traversal unit configured to perform traversal of the text resource identifiers in the text resource identifier set;
the value determining unit is configured to execute the step of determining a target value matched with the key in the compiling resource table by taking the text resource identifier as the key for each traversed text resource identifier;
and the first acquisition unit is configured to execute acquisition of the resource content corresponding to the target value, so as to obtain the text resource matched with the text resource identifier.
In an exemplary embodiment, the declaration unit includes:
the link label generating unit is configured to execute generation of a link label according to the target resource depended by the current page; the link label comprises a first attribute and a second attribute, wherein the first attribute indicates preloading, and the second attribute indicates a target resource on which the current page depends;
and the inserting unit is configured to insert the link tag into a head node of the entry file corresponding to the target page.
In an exemplary embodiment, the apparatus further comprises:
a second listening unit configured to perform listening for a link tag change event for the portal file; the link label changing event is used for triggering the change of the link label in the head node of the entry file;
and the execution unit is configured to execute the step of declaring the target resource depended by the current page as the pre-loading attribute in the entry file of the current page when the link tag change event is monitored.
In an exemplary embodiment, the first listening unit is specifically configured to execute a pre-page processing hook function in the page building tool to listen to a start processing event for a current page.
According to a third aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the page processing method of the first aspect.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium, wherein instructions of the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the page processing method of the first aspect.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program product comprising computer programs/instructions which, when executed by a processor, implement the page processing method of the first aspect described above.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
by monitoring a starting processing event aiming at a current page, determining a text resource identifier depended on by the current page when the starting processing event is monitored, further acquiring a text resource matched with the text resource identifier from a compiling resource table, searching each multimedia resource identifier in the compiling resource table in the text resource, if a certain multimedia resource identifier is found in the text resource, determining that the multimedia resource corresponding to the multimedia resource identifier is a target resource depended on by the current page, further declaring that the target resource depended on by the current page is a preloading attribute in an entry file of the current page, realizing that only the multimedia resource used by the current page is declared to be preloaded, excluding the preloading declaration of the multimedia resource which cannot be used by the current page, and thus only the multimedia resource used by the current page is preloaded in the preloading process of the current page, multimedia resources which cannot be used are not preloaded, so that the waste of network resources caused by unnecessary resource preloading is avoided, and the utilization rate of the network resources and the page preloading efficiency are improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
FIG. 1 is a flow diagram illustrating a method of page processing in accordance with an exemplary embodiment;
FIG. 2 is a flow diagram illustrating the determination of a text resource identification upon which a current page depends in accordance with an illustrative embodiment;
FIG. 3 is a flowchart illustrating declaring in an entry file of a current page that a target resource on which the current page depends is a preloaded attribute in accordance with an illustrative embodiment;
FIG. 4 is a block diagram illustrating a page processing apparatus according to an example embodiment;
FIG. 5 is a block diagram illustrating a resource preload plug-in accordance with an exemplary embodiment;
FIG. 6 is a block diagram illustrating an electronic device in accordance with an example embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
In the browser page, the network resource expected to be used can be declared as the preloading, so that the browser can perform the early loading of the network resource declared as the preloading in the idle time on the premise of not influencing the loading of the current page, and the rendering performance of the page is improved.
In the related art, in front-end engineering built based on a code compiling tool webpack, a default pre-loading plug-in preload-webpack-plug is generally used to automatically declare a resource to be pre-loaded by using a page building plug-in html-webpack-plug in an auxiliary webpack. The preload-webpack-plugin only supports preloading declarations in 4 forms, if multimedia resources such as pictures and videos are to be declared to be preloaded, declarations in all resource allAssets must be adopted, when the preloading declarations are in all resource allAssets, each page declares all resources to be preloaded if multiple pages exist in an application, namely resources which are not used by the page are still declared to be preloaded, and the fact that only the multimedia resources such as pictures and videos which are determined to be used by each page are declared to be preloaded cannot be achieved, and multimedia resources which are not used are not declared to be preloaded, so that all resources are required to be preloaded when the pages are preloaded, waste of network resources is caused, and the utilization rate of the network resources is reduced.
In view of this, embodiments of the present disclosure provide a page processing method, which may implement that only a multimedia resource declaration used for a page is determined as a preload, and a preload declaration of a multimedia resource that cannot be used for the page is excluded, so that only the multimedia resource determined to be used is preloaded in a preloading process of the page, and the multimedia resource that cannot be used is not preloaded, thereby avoiding a waste of network resources caused by unnecessary resource preloading, and improving a network resource utilization rate and a preload efficiency.
The page processing method of the embodiment of the disclosure can be implemented as a plug-in the webpack of the code compiling tool, for example, the plug-in can be referred to as a resource preloading plug-in, and the resource preloading plug-in can assist a page building plug-in html-webpack (or referred to as a page building tool) in the webpack of the code compiling tool to declare preloading only a target resource determined to be used in a page.
In practical application, when a browser loads a page, some multimedia resources such as pictures and videos hidden in text resources such as cascading Style css (cascading Style sheets) and script file JavaScript need to be loaded by the browser after the text resources are parsed, and therefore, it is necessary to declare multimedia resources such as pictures and videos hidden in the text resources and determined to be used by a corresponding page as preload in such a scenario. Based on this, in the embodiment of the present disclosure, the target resource declared by the resource preloading plugin is a multimedia resource determined to be used by a corresponding page in the cascading Style css (cascading Style sheets) and the JavaScript of the script file, and generally, multimedia resources such as pictures and videos in the text resource are generally in a binary form, so these multimedia resources may also be referred to as binary resources.
Referring to fig. 1, a flowchart illustrating a page processing method according to an exemplary embodiment is shown, where as shown in fig. 1, the method includes the following steps:
in step S11, a start processing event for the current page is listened to.
The current page is a page in the application compiled by the code compiling tool webpack, and the page is a page to be currently processed by a page building plug-in html-webpack in the code compiling tool webpack. For example, the application compiled by the code compiling tool webpack may include a plurality of pages, and the plurality of pages may be pages described by HyperText Markup Language (HTML).
Illustratively, in the code compiling tool webpack, a page building plug-in html-webpack-plug is used for building an entry html file of a page, and a hook function hook which can be called by other plug-ins is also provided in the page building plug-in html-webpack-plug, wherein the hook function hook includes a pre-page processing hook function html webpack plug-in before html processing, and the pre-page processing hook function is called before the page building plug-in html-plug processes a html page.
Therefore, when the above step S11 is implemented, the first preset hook function in the embodiment of the present disclosure may be a pre-page processing hook function htmlwebpackPlugBeforehtml processing provided in a page construction plug-in html-webpack-plug for constructing a target page, and the start processing event for the current page may be intercepted by the pre-page processing hook function htmlwebpackPlugBeforehtmlprocessing provided in the page construction tool html-webpack-plug.
In step S12, when the processing start event is monitored, a text resource identifier that the current page depends on is determined, and a text resource corresponding to the text resource identifier is stored in a compiled resource table.
Illustratively, when the page pre-processing hook function htmlwebpackPluginBeforeHtml processing is triggered, it indicates that a starting processing event of the current page is monitored, and at this time, the resource preloading plugin may determine a text resource identifier that the current page depends on, where the text resource identifier is used to uniquely identify a text resource that the current page depends on, and the text resource may include a JavaScript script file and a cascading style CSS file.
In an exemplary embodiment, the step S12 may include the following steps in fig. 2 when determining the text resource identifier that the current page depends on:
in step S121, data objects in the page building tool are determined.
The page construction tool is used for constructing the entry file of the target page, and specifically, the page construction tool may be a page construction plug-in html-webpack-plugin used for constructing the entry file of the target html page.
In step S122, resource code blocks are acquired from the data object.
In step S123, extracting the script file identifier and the stack style identifier that the current page depends on from the resource code block to obtain a text resource identifier set that the current page depends on; the text resource identifier in the text resource identifier set comprises the script file identifier and the stack style identifier.
Specifically, a page building plug-in html-webpack-plugin can expose a data object htmlPluginData, all script file identifications and cascading style identifications depended on by a current page are stored in the data object through a resource code block htmlPluginData.assets.chunks, but the resource code block does not store related resource identifications of other non-text resources (such as multimedia resources including picture resources, animation resources and the like), and therefore a text resource identification set depended on by the current page can be obtained by extracting script file identifications and cascading style identifications depended on by the current page from the resource code block htmlPluginData.assets.chunks. It should be noted that the resource code block htmlPluginData. assets. chunks only includes the text resource identifier, and does not include the text resource corresponding to the text resource identifier, and the text resource corresponding to the text resource identifier is stored in the compiling resource table, which will be introduced in the subsequent steps.
For example, the text resource identifier may be a name of the text resource, such as a file name of a JavaScript script file and a file name of a CSS file.
In practical applications, the JavaScript script file and the CSS file have different structures in the resource code block htmlPluginData. For the JavaScript script file, the single JavaScript script file name is used, and for the CSS file, the array is formed by a plurality of CSS file names, so that a text resource identifier set depending on a current page can be extracted through the resource code block htmlplug data.
In step S13, a text resource matching the text resource identifier is obtained from the compiled resource table.
And the text resource matched with the text resource identifier comprises a multimedia resource identifier corresponding to the current page.
Specifically, in the process that the code compiling tool webpack compiles the application corresponding to the current page, a compilation object or compilation object may be retrieved from the context of the code compilation tool webpack, the compiled object represents a single webpack compilation and process of generating compiled resources at a time, the resource content depended by all pages in the application corresponding to the current page and the resource identification corresponding to the resource content are recorded in the compiled object through a compiled resource table compatibility, wherein the resource content includes a text resource and a multimedia resource, and the resource identifier includes a text resource identifier corresponding to the text resource and a multimedia resource identifier corresponding to the multimedia resource, that is, the compilation resource table compilation. assets does not distinguish pages when recorded, it records all resources (i.e. text resources and multimedia resources) relied upon for compiling all pages in the application.
In an actual application, the compiling resource table compiling, assets and resource identifiers corresponding to resource content are recorded in the form that resource identifiers are keys and resource content corresponding to the resource identifiers is values, where based on this, in an exemplary embodiment, the step S13 may include the following steps in implementation:
(1) and traversing the text resource identification set depended by the current page.
(2) And for each traversed text resource identifier, determining a target value matched with the key in the compiling resource table by taking the text resource identifier as the key.
(3) And acquiring the resource content corresponding to the target value to acquire the text resource matched with the text resource identifier, so that the text resource corresponding to each text resource identifier in the text resource identifier set can be acquired when the traversal is finished.
Because the text resource identification points to the text resource which is depended on by the current page, namely the JavaScript file and the CSS file which are depended on by the current page, can be accurately found from all the pages related to the current compiling process through the steps.
In step S14, each multimedia resource identifier in the compiled resource table is searched in the text resource, and if the multimedia resource identifier is searched in the text resource, it is determined that the multimedia resource corresponding to the multimedia resource identifier is the target resource on which the current page depends.
Because the compiled resource table records the resource contents which are depended on by all the pages in the application corresponding to the current page and the resource identifications corresponding to the resource contents, namely the resource identifications appearing in the compiled resource table are definitely the resource identifications corresponding to the resources which are depended on by a certain page in the compiled application, namely the resources corresponding to the resource identifications are definitely used in the certain page, the resource content in the compiled resource table includes a text resource and a multimedia resource, and the resource identifier corresponding to the resource content includes a text resource identifier and a multimedia resource identifier, then, by searching each multimedia resource in the compiled resource table in the text resource depended by the current page, if a certain multimedia resource identifier in the compiled resource table is found in the text resource depended by the current page, it may be determined that the multimedia asset corresponding to the multimedia asset identification is a target asset on which the current page depends.
In step S15, the target resource that the current page depends on is declared as the preloaded attribute in the entry file of the current page.
In an exemplary embodiment, when the target resource on which the current page depends is declared as the preloaded attribute in the entry file of the current page, the following steps in fig. 3 may be included:
in step S151, a link label is generated according to the target resource on which the current page depends.
Wherein the link label comprises a first attribute and a second attribute, the first attribute indicating preloading and the second attribute indicating a target resource on which the current page depends.
In step S152, the link tag is inserted into the head node of the entry file corresponding to the target page.
For example, when the current page is an html page, the preloaded resource may be declared in the head node head of the entry file of the html page through a link tag, where the preload may be indicated through a rel attribute (i.e., a first attribute), and the target resource on which the current page depends is indicated through an href attribute (i.e., a second attribute).
Based on this, in an exemplary embodiment, as shown in the flowchart of another page processing method provided in fig. 4, before declaring, in the entry file of the current page, that the target resource on which the current page depends is the preloaded attribute, the method may further include the following steps:
in step S16, a link tag change event for the entry file is listened to.
Wherein the link label change event is used for triggering the change of the link label in the head node of the entry file. When the link label change event is monitored, the aforementioned step S15 in the embodiment of the present disclosure may be executed, and the target resource on which the current page depends is declared as the preloaded attribute in the entry file of the current page.
In practical application, the hook function provided by the page construction plug-in html-webpack-plugin comprises a link tag change hook function htmlwebpackPluginAlterAssetTags, and the trigger of the link tag change hook function htmlwebpackPluginAlterAssetTags is used as a cut-in point to change the link tag in the head node of the entry file of the current page. Therefore, the link tag change event for the entry file of the current page can be listened to through the link tag change hook function htmlWebPackPluginAlterAssetTags provided in the page building tool.
The embodiment of the disclosure realizes that only the multimedia resource determined to be used by the current page is declared as the preloading, and the preloading declaration of the multimedia resource which cannot be used by the current page is eliminated, so that only the multimedia resource determined to be used is preloaded in the preloading process of the current page, and the multimedia resource which cannot be used is not preloaded, thereby avoiding the waste of network resources caused by unnecessary resource preloading, and improving the utilization rate of the network resources and the page preloading efficiency.
Fig. 4 is a block diagram illustrating a page processing apparatus according to an example embodiment. Referring to fig. 5, the page processing apparatus 500 includes a first listening unit 410, a text resource identification determining unit 420, a text resource acquiring unit 430, a page dependent resource determining unit 440, and a clarification unit 450.
The first listening unit 410 configured to perform listening for a start processing event for a target page;
the text resource identifier determining unit 420 is configured to determine the text resource identifier that the current page depends on when the start processing event is monitored; the text resource corresponding to the text resource identifier is stored in a compiling resource table;
the text resource obtaining unit 430 is configured to perform obtaining of a text resource matching the text resource identifier from the compiled resource table; the text resource matched with the text resource identifier comprises a multimedia resource identifier corresponding to the current page;
the page dependency resource determining unit 440 is configured to perform searching for each multimedia resource identifier in the compiled resource table in the text resource, and if the multimedia resource identifier is found in the text resource, determine that the multimedia resource corresponding to the multimedia resource identifier is a target resource on which the current page depends;
the declaring unit 450 is configured to declare, in the entry file of the current page, that the target resource on which the current page depends is a preloaded attribute.
In an exemplary embodiment, the text resource identification determining unit 420 includes:
a data object determination unit configured to perform determining a data object in a page construction tool, the page construction tool being used for constructing an entry file of the current page;
a resource code block acquisition unit configured to perform acquisition of a resource code block from the data object;
an extracting unit, configured to extract the script file identifier and the stack style identifier that the current page depends on from the resource code block, to obtain a text resource identifier set that the current page depends on; the text resource identifier in the text resource identifier set comprises the script file identifier and the stack style identifier.
In an exemplary embodiment, the compiled resource table uses a resource identifier as a key, and the resource content corresponding to the resource identifier is recorded with the resource content depended on by all pages in the application corresponding to the current page and the resource identifier corresponding to the resource content in a form of a value; the resource content comprises a text resource and a multimedia resource, and the resource identifier comprises a text resource identifier corresponding to the text resource and a multimedia resource identifier corresponding to the multimedia resource;
the text resource acquiring unit 430 includes:
a traversal unit configured to perform traversal of the text resource identifiers in the text resource identifier set;
the value determining unit is configured to execute the step of determining a target value matched with the key in the compiling resource table by taking the text resource identifier as the key for each traversed text resource identifier;
and the first acquisition unit is configured to execute acquisition of the resource content corresponding to the target value, so as to obtain the text resource matched with the text resource identifier.
In an exemplary embodiment, the declaration unit 450 includes:
the link label generating unit is configured to execute generation of a link label according to the target resource depended by the current page; the link label comprises a first attribute and a second attribute, wherein the first attribute indicates preloading, and the second attribute indicates a target resource on which the current page depends;
and the inserting unit is configured to insert the link tag into a head node of the entry file corresponding to the target page.
In an exemplary embodiment, the apparatus further comprises:
a second listening unit configured to perform listening for a link tag change event for the portal file; the link label changing event is used for triggering the change of the link label in the head node of the entry file;
and the execution unit is configured to execute the step of declaring the target resource depended by the current page as the pre-loading attribute in the entry file of the current page when the link tag change event is monitored.
In an exemplary embodiment, the first listening unit 410 is specifically configured to execute a pre-page processing hook function in the page building tool to listen for a start processing event for a current page.
It should be noted that, when the apparatus provided in the foregoing embodiment implements the functions thereof, only the division of the functional modules is illustrated, and in practical applications, the functions may be distributed by different functional modules according to needs, that is, the internal structure of the apparatus may be divided into different functional modules to implement all or part of the functions described above.
For example, the page processing apparatus according to the embodiment of the disclosure may be a resource preloading plug-in, and the resource preloading plug-in may assist the code compilation tool webpack in the page building plug-in html-webpack to achieve that only multimedia resource declarations such as pictures and animations that are determined to be used in the html page are preloaded based on the page processing method according to the embodiment of the disclosure.
FIG. 5 is a block diagram illustrating a resource preload plug-in, which may include an Html cut-in module and a resource filter module, as shown in FIG. 5, in accordance with an exemplary embodiment.
The Html cut-in module is responsible for communicating with the page building plug-in, Html-webpack-plugin, and cutting into the Html page processing process at a proper time. Specifically, the Html cut-in module can monitor the starting processing event and the link label changing event of the page building plug-in Html-webpack-plug for the current Html page respectively through a page pre-processing hook function Html webpack plug for Html processing and a link label changing hook function Html webpack plug assentagttags in the page building plug-in Html-webpack-plug. When the Html cut-in module monitors the starting processing event of the current Html page, the resource screening module is called to accurately determine the multimedia resources such as pictures and animations used by the current Html page through the resource screening module. When the Html cut-in module monitors a link label changing event of the current Html page, inserting the determined multimedia resources such as pictures, animations and the like which are determined to be used by the current Html page into a head node of an entry file of the current Html page in a link label mode. It can be seen that the Html cut-in module can be used to implement the related functions of the first listening unit 410 and the declaration unit 450 in the page processing apparatus 400.
The resource screening module is responsible for determining multimedia resources such as pictures, animations, etc. determined to be used by the current html page, that is, the resource screening module may be used to implement the related functions of the text resource identifier determining unit 420, the text resource obtaining unit 430, and the page dependency resource determining unit 440 in the page processing apparatus.
The page processing device of the embodiment of the disclosure realizes that only the multimedia resource determined to be used by the current page is declared as the preload, the preload declaration of the multimedia resource that cannot be used by the current page is eliminated, and thus only the multimedia resource determined to be used by the current page is preloaded in the preloading process of the current page, multimedia resources which cannot be used are not preloaded, so that the waste of network resources caused by unnecessary resource preloading is avoided, and the utilization rate of the network resources and the page preloading efficiency are improved.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
In an exemplary embodiment, there is also provided an electronic device, comprising a processor; a memory for storing processor-executable instructions; when the processor is configured to execute the instructions stored in the memory, the page processing method provided in any of the above embodiments is implemented.
The electronic device may be a terminal, a server or a similar computing device, taking the electronic device as a terminal as an example, fig. 6 is a block diagram of an electronic device for page processing shown according to an exemplary embodiment, specifically:
the terminal may include RF (Radio Frequency) circuitry 610, memory 620 including one or more computer-readable storage media, input unit 630, display unit 640, sensor 650, audio circuitry 660, WiFi (wireless fidelity) module 670, processor 680 including one or more processing cores, and power supply 690. Those skilled in the art will appreciate that the terminal structure shown in fig. 6 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
the RF circuit 610 may be used for receiving and transmitting signals during information transmission and reception or during a call, and in particular, for receiving downlink information from a base station and then processing the received downlink information by the one or more processors 680; in addition, data relating to uplink is transmitted to the base station. In general, RF circuitry 610 includes, but is not limited to, an antenna, at least one Amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, an LNA (Low Noise Amplifier), a duplexer, and the like. In addition, the RF circuit 610 may also communicate with networks and other terminals through wireless communication. The wireless communication may use any communication standard or protocol, including but not limited to GSM (Global System for Mobile communications), GPRS (General Packet Radio Service), CDMA (Code Division Multiple Access), WCDMA (Wideband Code Division Multiple Access), LTE (Long Term Evolution), email, SMS (Short Messaging Service), and the like.
The memory 620 may be used to store software programs and modules, and the processor 680 may execute various functional applications and data processing by operating the software programs and modules stored in the memory 620. The memory 620 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, application programs required for functions, and the like; the storage data area may store data created according to the use of the terminal, and the like. Further, the memory 620 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 620 may also include a memory controller to provide the processor 680 and the input unit 630 access to the memory 620.
The input unit 630 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. In particular, the input unit 630 may include a touch sensitive surface 631 as well as other input devices 632. The touch sensitive surface 631, also referred to as a touch display screen or a touch pad, may collect touch operations by a user (e.g., operations by a user on the touch sensitive surface 631 or near the touch sensitive surface 631 using any suitable object or attachment such as a finger, a stylus, etc.) on or near the touch sensitive surface 631 and drive the corresponding connection device according to a predetermined program. Alternatively, the touch sensitive surface 631 may comprise two parts, a touch detection means and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 680, and can receive and execute commands sent by the processor 680. In addition, the touch sensitive surface 631 may be implemented using various types of resistive, capacitive, infrared, and surface acoustic waves. The input unit 630 may include other input devices 632 in addition to the touch-sensitive surface 631. In particular, other input devices 632 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 640 may be used to display information input by or provided to a user and various graphical user interfaces of the terminal, which may be made up of graphics, text, icons, video, and any combination thereof. The Display unit 640 may include a Display panel 641, and optionally, the Display panel 641 may be configured in the form of an LCD (Liquid Crystal Display), an OLED (Organic Light-Emitting Diode), or the like. Further, the touch-sensitive surface 631 may overlay the display panel 641, and when the touch-sensitive surface 631 detects a touch operation thereon or nearby, the touch operation is transmitted to the processor 680 to determine the type of the touch event, and then the processor 680 provides a corresponding visual output on the display panel 641 according to the type of the touch event. Where the touch sensitive surface 631 and the display panel 641 may implement input and output functions as two separate components, in some embodiments the touch sensitive surface 631 and the display panel 641 may be integrated to implement input and output functions.
The terminal may also include at least one sensor 650, such as a light sensor, motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor that adjusts the brightness of the display panel 641 according to the brightness of ambient light, and a proximity sensor that turns off the display panel 641 and/or a backlight when the terminal is moved to the ear. As one of the motion sensors, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally, three axes), detect the magnitude and direction of gravity when the terminal is stationary, and can be used for applications of recognizing terminal gestures (such as horizontal and vertical screen switching, related games, magnetometer gesture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured in the terminal, detailed description is omitted here.
Audio circuit 660, speaker 661, microphone 662 can provide an audio interface between a user and the terminal. The audio circuit 660 may transmit the electrical signal converted from the received audio data to the speaker 661, and convert the electrical signal into an audio signal through the speaker 661 for output; on the other hand, the microphone 662 converts the collected sound signal into an electrical signal, which is received by the audio circuit 660 and converted into audio data, which is then processed by the audio data output processor 680 and then passed through the RF circuit 610 to be transmitted to, for example, another terminal, or output to the memory 620 for further processing. The audio circuit 660 may also include an earbud jack to provide communication of peripheral headphones with the terminal.
WiFi belongs to a short-distance wireless transmission technology, and the terminal can help a user to send and receive e-mails, browse webpages, access streaming media and the like through the WiFi module 670, and provides wireless broadband internet access for the user. Although fig. 6 shows the WiFi module 670, it is understood that it does not belong to the essential constitution of the terminal, and can be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 680 is a control center of the terminal, connects various parts of the entire terminal using various interfaces and lines, and performs various functions of the terminal and processes data by operating or executing software programs and/or modules stored in the memory 620 and calling data stored in the memory 620, thereby integrally monitoring the terminal. Optionally, processor 680 may include one or more processing cores; preferably, the processor 680 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into processor 680.
The terminal also includes a power supply 690 (e.g., a battery) for powering the various components, which may be logically coupled to the processor 680 via a power management system to manage charging, discharging, and power consumption via the power management system. The power supply 690 may also include any component including one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and the like.
Although not shown, the terminal may further include a camera, a bluetooth module, and the like, which are not described herein again. In this embodiment, the terminal further includes a memory and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the one or more processors. The one or more programs include instructions for performing the page processing method provided by the above-described method embodiments.
In an exemplary embodiment, a computer-readable storage medium comprising instructions, such as the memory 620 comprising instructions, executable by the processor 680 of the apparatus 600 to perform the method described above is also provided. Alternatively, the computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
In an exemplary embodiment, there is also provided a computer program product comprising computer programs/instructions which, when executed by a processor, implement the page processing method provided in any of the above embodiments.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (10)

1. A page processing method is characterized by comprising the following steps:
monitoring a starting processing event aiming at a current page;
when the starting processing event is monitored, determining a text resource identifier which is depended by the current page; the text resource corresponding to the text resource identifier is stored in a compiling resource table;
acquiring a text resource matched with the text resource identifier from the compiling resource table; the text resource matched with the text resource identifier comprises a multimedia resource identifier corresponding to the current page;
searching each multimedia resource identifier in the compiling resource table in the text resource, and if the multimedia resource identifier is searched in the text resource, determining that the multimedia resource corresponding to the multimedia resource identifier is a target resource which is depended on by the current page;
and declaring the target resource which is depended by the current page as a preloading attribute in the entry file of the current page.
2. The page processing method according to claim 1, wherein said determining the text resource identifier on which the current page depends comprises:
determining a data object in a page construction tool, wherein the page construction tool is used for constructing an entry file of the current page;
acquiring a resource code block from the data object;
extracting a script file identifier and a stacking style identifier which are depended by the current page from the resource code block to obtain a text resource identifier set depended by the current page; the text resource identifier in the text resource identifier set comprises the script file identifier and the stack style identifier.
3. The page processing method according to claim 2, wherein the compiled resource table uses a resource identifier as a key, and the resource content corresponding to the resource identifier is a value, and the resource content that all pages in the application corresponding to the current page depend on and the resource identifier corresponding to the resource content are recorded; the resource content comprises a text resource and a multimedia resource, and the resource identifier comprises a text resource identifier corresponding to the text resource and a multimedia resource identifier corresponding to the multimedia resource;
the obtaining of the text resource matched with the text resource identifier from the compiled resource table includes:
traversing the text resource identifiers in the text resource identifier set;
for each traversed text resource identifier, determining a target value matched with the key in the compiling resource table by taking the text resource identifier as the key;
and acquiring the resource content corresponding to the target value to obtain the text resource matched with the text resource identifier.
4. The method for processing pages according to claim 1, wherein said declaring, in the entry file of the current page, that the target resource on which the current page depends is a preloaded attribute comprises:
generating a link label according to the target resource depended by the current page; the link label comprises a first attribute and a second attribute, wherein the first attribute indicates preloading, and the second attribute indicates a target resource on which the current page depends;
and inserting the link label into a head node of an entry file corresponding to the target page.
5. The page processing method according to claim 4, wherein before declaring in the entry file of the current page that the target resource on which the current page depends is a preloaded attribute, the method further comprises:
monitoring a link label change event aiming at the entry file; the link label changing event is used for triggering the change of the link label in the head node of the entry file;
and when the link label change event is monitored, the step of declaring the target resource depended by the current page as the pre-loading attribute in the entry file of the current page is executed.
6. The page processing method according to claim 2, wherein said listening for a start processing event for a current page comprises:
and monitoring a starting processing event aiming at the current page through a page processing front hook function in the page construction tool.
7. A page processing apparatus, comprising:
a first listening unit configured to perform listening for a start processing event for a target page;
a text resource identification determining unit configured to determine a text resource identification on which the current page depends when the start processing event is monitored; the text resource corresponding to the text resource identifier is stored in a compiling resource table;
a text resource obtaining unit configured to perform obtaining of a text resource matching the text resource identifier from the compiled resource table; the text resource matched with the text resource identifier comprises a multimedia resource identifier corresponding to the current page;
a page dependency resource determining unit, configured to perform searching for each multimedia resource identifier in the compiled resource table in the text resource, and if the multimedia resource identifier is searched for in the text resource, determine that the multimedia resource corresponding to the multimedia resource identifier is a target resource on which the current page depends;
and the declaration unit is configured to declare the target resource depended by the current page as the preloading attribute in the entry file of the current page.
8. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the page processing method of any of claims 1 to 6.
9. A computer-readable storage medium whose instructions, when executed by a processor of an electronic device, enable the electronic device to perform the page processing method of any of claims 1 to 6.
10. A computer program product comprising computer programs/instructions, characterized in that the computer programs/instructions, when executed by a processor, implement the page processing method of any of claims 1 to 6.
CN202110223983.5A 2021-02-26 2021-02-26 Page processing method and device, electronic equipment and storage medium Pending CN113065083A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110223983.5A CN113065083A (en) 2021-02-26 2021-02-26 Page processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110223983.5A CN113065083A (en) 2021-02-26 2021-02-26 Page processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113065083A true CN113065083A (en) 2021-07-02

Family

ID=76559226

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110223983.5A Pending CN113065083A (en) 2021-02-26 2021-02-26 Page processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113065083A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113326456A (en) * 2021-07-08 2021-08-31 北京达佳互联信息技术有限公司 Webpage resource acquisition method, device, equipment, system and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113326456A (en) * 2021-07-08 2021-08-31 北京达佳互联信息技术有限公司 Webpage resource acquisition method, device, equipment, system and storage medium

Similar Documents

Publication Publication Date Title
CN108880867B (en) Network equipment data acquisition method and system
CN105429775B (en) Method and device for reporting log
US10853437B2 (en) Method and apparatus for invoking application programming interface
CN107393548B (en) Method and device for processing voice information collected by multiple voice assistant devices
CN106502703B (en) Function calling method and device
US20140365892A1 (en) Method, apparatus and computer readable storage medium for displaying video preview picture
WO2018196588A1 (en) Information sharing method, apparatus and system
CN108984374B (en) Method and system for testing database performance
CN108287918B (en) Music playing method and device based on application page, storage medium and electronic equipment
CN111178012A (en) Form rendering method, device and equipment and storage medium
CN113065083A (en) Page processing method and device, electronic equipment and storage medium
CN111273955A (en) Thermal restoration plug-in optimization method and device, storage medium and electronic equipment
CN105095161B (en) Method and device for displaying rich text information
CN112000566A (en) Test case generation method and device
CN108304369B (en) File type identification method and device
CN104063400A (en) Data search method and data search device
CN108959062B (en) Webpage element acquisition method and device
CN106156097B (en) Method and device for processing browser input records
CN110022189B (en) Data transmission method, device, terminal and storage medium
CN110198324B (en) Data monitoring method and device, browser and terminal
CN112749074A (en) Test case recommendation method and device
CN110347578B (en) Application testing method and device and storage medium
CN107346347B (en) Webpage table display method and device
CN109240986B (en) Log processing method and device and storage medium
CN107798008B (en) Content pushing system, method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination