Page processing method, device, equipment, readable storage medium and product

The method ensures all browsers can implement delayed loading by distinguishing between supporting and non-supporting browsers, enhancing loading efficiency and performance.

CN114817807BActive Publication Date: 2024-12-20CHINA CONSTRUCTION BANK
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210452721.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-27
Publication Date
2024-12-20
Estimated Expiration
2042-04-27

AI Technical Summary

Technical Problem

Not all browsers support lazy loading, which affects the efficiency of delayed loading and page performance.

Method used

A method to identify browsers that support or do not support delayed loading, and apply specific attribute modifications to target elements to enable delayed loading for both types of browsers, using a content distribution network address and a loading attribute.

Benefits of technology

Enables delayed loading for all browsers, improving loading efficiency and page performance by shortening loading time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114817807B_ABST
    Figure CN114817807B_ABST
Patent Text Reader

Abstract

The present application relates to the field of computer technology, and in particular to a page processing method, device, equipment, readable storage medium and product. When a target page is loaded using a first browser, the initial address attribute of a target element on the target page is obtained, the attribute value of the initial address attribute of the target element is assigned to the target address attribute and the initial address attribute of the target element is deleted, a delayed loading attribute is added to the class attribute of the target element, and a script tag is created for the target element, and the content distribution network address of the delayed loading is configured as the initial address attribute of the script tag, so that the first browser can delay loading of the target element. When a second browser is used to load the target page, a loading attribute is added to the target element, and the attribute value of the loading attribute is marked as delayed, so that the second browser can delay loading of the target element. In this way, all browsers can delay loading of the target element, thereby improving the efficiency of delayed loading.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a page processing method, device, equipment, readable storage medium and product. Background Art

[0002] Web page performance refers to the time it takes for a page to load and become interactive and responsive, as well as the smoothness of the page when interacting. The worse the web page performance, the longer the page loads.

[0003] Currently, you can shorten page loading time and improve page performance through lazy loading. Lazy loading is a strategy that identifies resources as non-blocking (non-critical) resources and loads them only when needed.

[0004] However, not all browsers can implement lazy loading, which affects the efficiency of lazy loading. Summary of the invention

[0005] The present application provides a page processing method, apparatus, device, readable storage medium and product, so that all browsers can implement delayed loading and improve the efficiency of delayed loading.

[0006] In a first aspect, the present application provides a page processing method, comprising:

[0007] Obtain a target page and an array of browsers running on the website, and filter a first browser that does not support delayed loading and a second browser that supports delayed loading in the browser array;

[0008] When the target page is loaded by the first browser, an initial address attribute of a target element on the target page is obtained, an attribute value of the initial address attribute of the target element is assigned to the target address attribute and the initial address attribute of the target element is deleted, a delayed loading attribute is added to the class attribute of the target element, a script tag is created for the target element, and a content distribution network address of a delayed loading library is configured as the initial address attribute of the script tag, so that the first browser delays loading the target element by using the target plug-in;

[0009] When the target page is loaded by the second browser, a loading attribute is added to the target element on the target page, and the attribute value of the loading attribute is marked as delayed, so that the second browser delays loading of the target element by using the target plug-in.

[0010] Optionally, adding a loading attribute to the target element on the target page and marking the attribute value of the loading attribute as delayed, so that the second browser uses the target plug-in to delay loading of the target element, specifically includes:

[0011] The initial element on the target page is obtained, target elements that do not have an immediate loading attribute in the initial elements are filtered, a loading attribute is added to the target element, and the attribute value of the loading attribute is marked as delayed, so that the second browser uses the target plug-in to delay loading of the target element.

[0012] Optionally, acquiring the initial element on the target page, screening the target elements that do not have an immediate load attribute in the initial elements, adding a load attribute to the target element, and marking the attribute value of the load attribute as delayed, so that the second browser uses the target plug-in to delay loading of the target element, specifically includes:

[0013] Obtain the initial image element on the target page, filter out the target image elements that do not have an immediate loading attribute in the initial image elements, add a loading attribute to the target image elements, and mark the attribute value of the loading attribute as delayed, so that the second browser uses the target plug-in to delay loading of the target image elements.

[0014] Optionally, acquiring the initial element on the target page, screening the target elements that do not have an immediate load attribute in the initial elements, adding a load attribute to the target element, and marking the attribute value of the load attribute as delayed, so that the second browser uses the target plug-in to delay loading of the target element, specifically includes:

[0015] The initial frame element on the target page is obtained, target frame elements that do not have an immediate loading attribute are filtered out from the initial frame elements, a loading attribute is added to the target frame element, and the attribute value of the loading attribute is marked as delayed, so that the second browser uses the target plug-in to delay loading of the target frame element.

[0016] Optionally, obtaining the image element on the target page specifically includes:

[0017] Parsing the target page into a syntax tree using a hypertext markup language parser;

[0018] The elements whose element names are pictures or frames in the syntax tree are traversed in a loop.

[0019] Optionally, the filtering of the first browser that does not support delayed loading and the second browser that supports delayed loading in the browser array specifically includes:

[0020] The first target library is used to determine whether each browser in the browser array supports delayed loading, and a first browser that does not support delayed loading and a second browser that supports delayed loading in the browser array are screened out.

[0021] Optionally, obtaining an array of browsers running the website specifically includes:

[0022] The browser operating environment of the website is obtained, and a matching browser array is obtained according to the browser operating environment of the website.

[0023] Optionally, obtaining a matching browser array according to the browser environment in which the website runs specifically includes:

[0024] The browser operating environment of the website is obtained by using the second target library, and the second target library parses the target attribute of the first target file or the second target file in the browser operating environment to obtain a browser array matching the target attribute of the first target file or the second target file.

[0025] Optionally, the filtering of the first browser that does not support delayed loading and the second browser that supports delayed loading in the browser array specifically includes:

[0026] Determine whether all browsers in the browser array support delayed loading. If so, mark all browsers as second browsers. If not, filter out browsers that support delayed loading and browsers that do not support delayed loading in the browser array, mark the browsers that support delayed loading as second browsers, and mark the browsers that do not support delayed loading as first browsers.

[0027] In a second aspect, the present application provides a page processing device, comprising:

[0028] An acquisition module, used to acquire a target page and an array of browsers running on the website, and screen a first browser that does not support delayed loading and a second browser that supports delayed loading in the browser array;

[0029] A first delay module is used for, when the target page is loaded by the first browser, obtaining an initial address attribute of a target element on the target page, assigning an attribute value of the initial address attribute of the target element to a target address attribute and deleting the initial address attribute of the target element, adding a delayed loading attribute to a class attribute of the target element, creating a script tag for the target element, and configuring a content distribution network address of a delayed loading library as the initial address attribute of the script tag, so that the first browser delays loading the target element by using a target plug-in;

[0030] The second delay module is used to add a loading attribute to the target element on the target page when the target page is loaded by the second browser, and mark the attribute value of the loading attribute as delayed, so that the second browser uses the target plug-in to delay loading of the target element.

[0031] In a third aspect, the present application provides an electronic device, including: a memory and a processor;

[0032] The memory is used to store instructions; the processor is used to call the instructions in the memory to execute the page processing method in the first aspect and any possible design of the first aspect.

[0033] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer instructions are stored. When at least one processor of an electronic device executes the computer instructions, the electronic device executes the page processing method in the first aspect and any possible design of the first aspect.

[0034] In a fifth aspect, the present application provides a computer program product, which includes computer instructions. When at least one processor of an electronic device executes the computer instructions, the electronic device executes the page processing method in the first aspect and any possible design of the first aspect.

[0035] The page processing method provided by the present application obtains the target page and the browser array running by the website browser, and screens the first browser that does not support delayed loading and the second browser that supports delayed loading in the browser data. When the target page is loaded by the first browser, the initial address attribute of the target element on the target page is obtained, the attribute value of the initial address attribute of the target element is assigned to the target address attribute and the initial address attribute of the target element is deleted, the delayed loading attribute is added to the class attribute of the target element, and a script tag is created for the target element, and the content distribution network address of the delayed loading is configured as the initial address attribute of the script tag, so that the browser that does not support delayed loading can use the target plug-in to delay the loading of the target element on the target page. When the target page is loaded by the second browser, the loading attribute is added to the target element on the target page, and the attribute value of the loading attribute is marked as delayed, so that the second browser that supports delayed loading can use the target plug-in to delay the loading of the target element on the target page. In this way, both the browser that supports delayed loading and the browser that does not support delayed loading can realize the delayed loading of the target element, thereby improving the efficiency of delayed loading. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the technical solutions in the present application or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0037] Figure 1 A flow chart of a page processing method provided in one embodiment of the present application;

[0038] Figure 2 A flow chart of a page processing method provided in one embodiment of the present application;

[0039] Figure 3 A schematic diagram of the structure of a page processing device provided in one embodiment of the present application;

[0040] Figure 4 A schematic diagram of the hardware structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0041] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0042] Currently, lazy loading can be used to shorten page loading time and improve page performance. However, not all browsers can implement lazy loading, which affects lazy loading efficiency. However, not all browsers can implement lazy loading, which affects lazy loading efficiency.

[0043] In view of the above problems, the present application proposes a page processing method, which obtains a target page and a browser array running on a website, and screens a first browser that does not support delayed loading and a second browser that supports delayed loading in the browser array. When the target page is loaded using the first browser that does not support delayed loading, the initial address attribute of the target element on the target page is obtained, the attribute value of the initial address attribute of the target element is assigned to the target address attribute and the initial address attribute of the target element is deleted, a delayed loading attribute is added to the class attribute of the target element, a script tag is created for the target element, and the content distribution network address of the delayed loading library is used as the initial address attribute of the script tag, so that the first browser that does not support delayed loading can also realize delayed loading of the target element on the target page. When the target page is loaded using the second browser that supports delayed loading, a loading attribute is added to the target element on the target page, and the attribute value of the loading attribute is marked as delayed, so that the second browser that supports delayed loading can delay loading the target element on the target page. In this way, both the browser that supports delayed loading and the browser that does not support delayed loading can delay loading of the target element, improve the efficiency of delayed loading, shorten the loading time, and improve page performance.

[0044] The technical solution of the present application is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0045] An embodiment of the present application provides a scenario of page processing. The server obtains the target page and the browser array running on the website, and determines whether all browsers in the browser array support delayed loading. If so, the server marks all browsers as the second browser. If not, the server screens out the browsers that do not support delay and the browsers that support delayed loading in the browser array, marks the browsers that do not support delayed loading as the first browser, and marks the browsers that support delayed loading as the second browser. When the target page is loaded using the first browser, the server obtains the initial address attribute of the target element on the target page, assigns the attribute value of the initial address attribute of the target element to the target address attribute and deletes the initial address attribute of the target element, adds a delayed loading attribute to the class attribute of the target element, creates a script tag for the target element, configures the content distribution network address of the delayed loading library as the initial address attribute of the script tag, so that the first browser can use the target plug-in to delay loading of the target element on the target page. When the target page is loaded using the second browser, the server adds a loading attribute to the target element on the target page, and marks the attribute value of the loading attribute as delayed, so that the second browser can use the target plug-in to delay loading of the target element on the target page.

[0046] Figure 1 The following is a flow chart of a page processing method provided by an embodiment of the present application. With the server as the execution subject, the method of this embodiment may include the following steps:

[0047] S101, obtaining a target page and an array of browsers running on the website, and screening a first browser that does not support delayed loading and a second browser that supports delayed loading in the browser array.

[0048] For example, a website is a web website. Before a website goes online, it needs to be built by a build tool before it can be deployed online. Common build tools include webpack, rollup, gulp, etc. The build tool performs static analysis based on the dependencies of the website's modules, and then generates corresponding static resources for the website's modules according to specified rules, such as compiling high-version JavaScript code (ES6) into JavaScript code (ES5) with higher browser support, compiling preprocessing languages ​​such as LESS (Leaner Style Sheets) and SCSS (Sassy Cascading Style Sheets) into CSS (Cascading Style Sheets) code, html (HyperText Markup Language) file processing, and image resource compression. The product of the build tool is static resource files, including html files, css style files, JavaScript files, image resources, and font resources. Html files are files that can be opened by browsers, css style files are style files for website pages, and JavaScript files are files for website interaction.

[0049] The target page is the page to be loaded. In some embodiments, the target page may be an HTML page, which may contain non-text elements such as pictures, links, music, and programs.

[0050] In some embodiments, the target attribute can be configured in the second target file, or the first target file can be newly created in the project root directory to configure the browser operating environment for the web, that is, the browser operating environment of the web includes the target attribute of the first target file or the second target file. Therefore, after obtaining the browser operating environment of the website, a matching browser array can be obtained according to the browser operating environment of the website. Specifically, after obtaining the browser operating environment of the website, the target attribute of the first target file or the second target file in the browser operating environment is parsed to obtain browsers that match the target attribute of the first target file or the second target file, and the browsers that match the target attribute of the first target file or the second target file are integrated into a browser array.

[0051] As an implementation method, the first target file is a browserslistrc file, the second target file is a package.json file, and the target attribute is browserslist. The second target library is used to obtain the browser operating environment of the website. The second target library can parse whether there is a browserslistrc file or a target attribute of the package.json file in the browser operating environment. When there is a browserslistrc file or a target attribute of the package.json file in the browser operating environment, a browser matching the target attribute of the browserslistrc file or the package.json file is obtained, thereby obtaining an array of browsers matching the browser operating environment. For example, browserslist is used to obtain the browser environment in which the web site runs. Browserslist parses the package.json file or .browserslistrc file that configures the browserslist attribute in the web site to obtain a browser matching the web site operating environment.

[0052] Some browsers can support the delayed loading feature of the browser, while some browsers cannot support it. For example, IE, low-version Edge, low-version Firefox, low-version Safari and other browsers do not support delayed loading, while high-version Edge, high-version Firefox, high-version Safari and other browsers support delayed loading. Therefore, after obtaining the browser array running the website, the browsers that do not support delayed loading and the browsers that support delayed loading in the browser array are screened, and the browsers that do not support delayed loading are marked as the first browser, and the browsers that delay loading are marked as the second browser.

[0053] In some embodiments, the first target library can be used to determine whether each browser in the browser array supports lazy loading, so as to screen out the first browser that does not support lazy loading and the second browser that supports lazy loading. The first target library can be, for example, caniuse-lite, which can determine whether the browser supports lazy loading (loadinglazy) attribute, thereby determining whether the browser supports lazy loading.

[0054] S102. When the target page is loaded by the first browser, the initial address attribute of the target element on the target page is obtained, the attribute value of the initial address attribute of the target element is assigned to the target address attribute and the initial address attribute of the target element is deleted, a delayed loading attribute is added to the class attribute of the target element, and a script tag is created for the target element, and the content distribution network of the delayed loading library is configured as the initial address attribute of the script tag, so that the first browser uses the target plug-in to delay loading the target element.

[0055] In some embodiments, the target page can be parsed into a syntax tree by a hypertext markup language parser. The syntax tree is a tree-shaped parsing structure, which is convenient for subsequent acquisition of the target element. The hypertext markup language parser can be, for example, parse5. After obtaining the syntax tree, the elements whose element names (nodeName) are pictures (img) or frames (iframe) in the syntax tree are looped through to obtain the target element. Therefore, the target element here is the element whose element name is picture or frame in the syntax tree.

[0056] It should be noted that even if the browser does not support lazy loading, the target element on the target page can be processed so that the browser that does not support lazy loading can delay loading the target element. When a browser that does not support lazy loading needs to load the target page, the target element on the target page is processed, and the first browser that does not support lazy loading is made to delay loading the target element with the help of the lazy loading library (lazysizes). The first browser that does not support lazy loading can also be understood as a low-version browser.

[0057] When the target page is loaded by the first browser that does not support delayed loading, the initial address (src) attribute of the target element on the target page is obtained, the initial address attribute of the target element refers to the storage path of the target element itself, the attribute value of the initial address attribute of the target element is assigned to the target address (data-src) attribute, and the initial address attribute of the target element is deleted, so that the target element can still be stored in the storage path of the target element after deleting the initial address attribute of the target element. Then, a lazy load attribute is added to the class attribute of the target element, and a script tag is created for the target element. It is determined whether the delayed loading library is configured with a content distribution network (SDN) address. If so, the content distribution network address of the delayed loading library is configured as the initial address attribute of the script tag. If not, the default content distribution network address is configured as the initial address attribute of the script tag. Since the class attribute of the target element includes the delayed loading attribute, the script tag of the target element includes the initial address attribute, so that the first browser that does not support delayed loading can delay loading the target element.

[0058] It should be noted that when the browser loads the target page, it needs to use the target plug-in to load the target element on the target page. The target plug-in can be a webpack plug-in. When the target page is loaded by the first browser that does not support delayed loading, the hook function (hook) of the html-webpack-plugin plug-in in the webpack plug-in can be used to process the target page so that the target element on the target page can support delayed loading. Then, the first browser can use the target plug-in to delay the loading of the target element.

[0059] S103: When the target page is loaded by the second browser, a loading attribute is added to a target element on the target page, and the attribute value of the loading attribute is marked as delayed, so that the second browser delays loading of the target element by using the target plug-in.

[0060] In some embodiments, the target page can be parsed into a syntax tree by a hypertext markup language parser, and the syntax tree is a tree-shaped parsing structure, which is convenient for subsequent acquisition of target elements. After obtaining the syntax tree, loop through the elements whose element names (nodeName) are pictures (img) or frames (iframe) in the syntax tree to obtain the initial elements. It is determined whether the initial elements have an immediate loading (data-loading) attribute, and elements that do not have the immediate loading attribute are screened out as target elements. Therefore, the target element here is an element whose element name in the syntax tree is a picture or a frame and does not have an immediate loading attribute.

[0061] A loading attribute is added to the target element, and the attribute value of the loading attribute is marked as lazy. Since the second browser supports the lazy loading feature, when the attribute value of the loading attribute of the target element is lazy, the second browser can delay loading of the target element.

[0062] In some embodiments, an initial image element on a target page is obtained, target image elements that do not have an immediate loading attribute are filtered out from the initial image elements, a loading attribute is added to the target image element, and the loading attribute of the target image element is marked as delayed, so that a second browser can use a target plug-in to delay loading of the target image element.

[0063] In some embodiments, an initial frame element on a target page is obtained, target frame elements that do not have an immediate loading attribute are filtered out from the initial frame elements, a loading attribute is added to the target frame element, and the loading attribute of the target frame element is marked as delayed, so that a second browser can use a target plug-in to delay loading of the target frame element.

[0064] The page processing method provided by the present application, when the target page is loaded by the first browser that does not support delayed loading, the initial address attribute of the target element on the target page is obtained, the attribute value of the initial address attribute of the target element is assigned to the target address attribute and the initial address attribute of the target element is deleted, the delayed loading attribute is added to the class attribute of the target element, a script tag is created for the target element, and the content distribution network address of the delayed loading library is used as the initial address attribute of the script tag, so that the first browser that does not support delayed loading can also realize delayed loading of the target element on the target page. When the target page is loaded by the second browser that supports delayed loading, a loading attribute is added to the target element on the target page, and the attribute value of the loading attribute is marked as delayed, so that the second browser that supports delayed loading can delay loading the target element on the target page. In this way, all browsers can delay loading of the target element, improve the efficiency of delayed loading, shorten the loading time, and improve page performance.

[0065] Figure 2 FIG. 1 is a flow chart of a page processing method provided by an embodiment of the present application. Figure 2 As shown, with the server as the execution subject, the method of this embodiment may include the following steps:

[0066] S201, obtaining a target page and an array of browsers running the website, and determining whether all browsers in the browser array support delayed loading.

[0067] The target page is the page to be loaded. The page to be loaded and all browsers matching the browser operating environment of the website are obtained to determine whether all browsers support delayed loading. For example, for the same browser, caniuse-lite can be used to perform delayed loading judgment on the lowest or highest version of the browser. If the lowest version of the browser supports delayed loading, then all browsers of this browser support delayed loading. If the highest version of the browser does not support delayed loading, then all browsers of this browser do not support delayed loading. Therefore, when the browser array includes multiple types of browsers, such as Edge, Firefox, and Safari, only the lowest version and / or highest version of the same browser can be judged for delayed loading to improve efficiency.

[0068] If all browsers support delayed loading, execute step S202; if some browsers do not support delayed loading, execute step S203.

[0069] S202: Mark all browsers as second browsers.

[0070] The second browser refers to a browser that supports lazy loading.

[0071] S203, filtering the browsers that do not support delayed loading in the browser array, marking the browsers that do not support delayed loading as the first browser, filtering the browsers that support delayed loading in the browser array, marking the browsers that support delayed loading as the second browser.

[0072] When some browsers do not support delayed loading, a second browser that supports delayed loading and a first browser that does not support delayed loading are distinguished.

[0073] S204. When the target page is loaded by the first browser, the initial address attribute of the target element on the target page is obtained, the attribute value of the initial address attribute of the target element is assigned to the target address attribute and the initial address attribute of the target element is deleted, a delayed loading attribute is added to the class attribute of the target element, and a script tag is created for the target element, and the content distribution network of the delayed loading library is configured as the initial address attribute of the script tag, so that the first browser delays loading of the target element.

[0074] S205: When the target page is loaded by the second browser, a loading attribute is added to a target element on the target page, and the attribute value of the loading attribute is marked as delayed, so that the second browser delays loading of the target element.

[0075] Among them, step S204 and Figure 1 The implementation of step S102 in the embodiment is similar, and will not be repeated here in this embodiment. Figure 1 The implementation of step S103 in the embodiment is similar and will not be described in detail in this embodiment.

[0076] The page processing method provided by the present application determines whether all browsers support delayed loading. When some browsers do not support delayed loading, the method further distinguishes between browsers that support delayed loading and browsers that do not support delayed loading, thereby improving efficiency. Then, when a target page is loaded using a browser that supports delayed loading or a browser that does not support delayed loading, the target page is processed differently, so that both browsers that support delayed loading and browsers that do not support delayed loading can delay loading of the target element, thereby improving delayed loading efficiency, shortening loading time, and improving page performance.

[0077] Figure 3 A schematic diagram of the structure of a page processing device provided by an embodiment of the present application is shown. Figure 3 As shown, the page processing device 10 of this embodiment includes:

[0078] An acquisition module 11 is used to acquire a target page and an array of browsers running on the website, and filter a first browser that does not support delayed loading and a second browser that supports delayed loading in the browser array;

[0079] The first delay module 12 is used for, when the target page is loaded by the first browser, obtaining the initial address attribute of the target element on the target page, assigning the attribute value of the initial address attribute of the target element to the target address attribute and deleting the initial address attribute of the target element, adding a delayed loading attribute to the class attribute of the target element, creating a script tag for the target element, and configuring the content distribution network address of the delayed loading library as the initial address attribute of the script tag, so that the first browser delays the loading of the target element by using the target plug-in;

[0080] The second delay module 13 is used to add a loading attribute to a target element on the target page and mark the attribute value of the loading attribute as delayed when the target page is loaded by the second browser, so that the second browser delays loading of the target element by using the target plug-in.

[0081] The page processing device 10 provided in the embodiment of the present application can execute the above method embodiment. Its specific implementation principle and technical effects can be found in the above method embodiment, and this embodiment will not be repeated here.

[0082] Figure 4 FIG. 1 shows a hardware structure diagram of an electronic device provided in an embodiment of the present application. Figure 4 As shown, the electronic device 20 of this embodiment may include: a memory 21 , a processor 22 and a communication interface 23 .

[0083] The memory 21 is used to store computer instructions. The memory 21 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (NVM), such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a disk or an optical disk.

[0084] The processor 22 is used to execute the computer instructions stored in the memory to implement the page processing method in the above embodiment. For details, please refer to the relevant description in the above method embodiment. The processor 22 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the invention can be directly embodied as being executed by a hardware processor, or can be executed by a combination of hardware and software modules in the processor.

[0085] Optionally, the memory 21 may be independent or integrated with the processor 22 .

[0086] The communication interface 23 may be connected to the processor 22. The processor 22 may control the communication interface 23 to implement the functions of receiving and sending information.

[0087] The electronic device provided in this embodiment can be used to execute the above-mentioned page processing method, and its implementation method and technical effect are similar, which will not be described in detail in this embodiment.

[0088] The present application also provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed by a processor, they are used to implement the methods provided in the various embodiments described above.

[0089] The present application also provides a computer program product, which includes computer instructions stored in a computer-readable storage medium. At least one processor of a device can read the computer instructions from the computer-readable storage medium, and at least one processor executes the computer instructions so that the device implements the methods provided in the various embodiments described above.

[0090] An embodiment of the present application also provides a chip, which includes a memory and a processor, wherein the memory is used to store computer instructions, and the processor is used to call and execute the computer instructions from the memory, so that a device equipped with the chip executes the methods described in the various possible implementation modes above.

[0091] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the above embodiments can still be modified, or some or all of the technical features can be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A page processing method, characterized in that: The method comprises: Obtain a target page and an array of browsers running on the website, and filter a first browser that does not support delayed loading and a second browser that supports delayed loading in the browser array; When the target page is loaded by the first browser, the initial address attribute of the target element on the target page is obtained, the attribute value of the initial address attribute of the target element is assigned to the target address attribute and the initial address attribute of the target element is deleted, a delayed loading attribute is added to the class attribute of the target element, and a script tag is created for the target element, and it is determined whether the delayed loading library is configured with a content distribution network address, and if so, the content distribution network address of the delayed loading library is configured as the initial address attribute of the script tag, so that the first browser uses the target plug-in to delay loading the target element; wherein, if the delayed loading library is not configured with a content distribution network address, a default content distribution network address is configured as the initial address attribute of the script tag; When the target page is loaded by the second browser, a loading attribute is added to a target element on the target page, and an attribute value of the loading attribute is marked as delayed, so that the second browser delays loading of the target element by using the target plug-in; The step of screening the first browser that does not support delayed loading and the second browser that supports delayed loading in the browser array specifically includes: The first target library is used to determine whether each browser in the browser array supports delayed loading. If so, all browsers are marked as second browsers. If not, browsers that support delayed loading and browsers that do not support delayed loading in the browser array are screened out, and browsers that support delayed loading are marked as second browsers, and browsers that do not support delayed loading are marked as first browsers. When the browser array includes multiple types of browsers, the lowest version and / or highest version of the same browser is judged for delayed loading.

2. The method according to claim 1, characterized in that The step of adding a loading attribute to the target element on the target page and marking the attribute value of the loading attribute as delayed, so that the second browser uses the target plug-in to delay loading of the target element, specifically includes: The initial element on the target page is obtained, target elements that do not have an immediate loading attribute in the initial elements are filtered, a loading attribute is added to the target element, and the attribute value of the loading attribute is marked as delayed, so that the second browser uses the target plug-in to delay loading of the target element.

3. The method according to claim 2, characterized in that The obtaining of the initial element on the target page, screening the target elements that do not have an immediate loading attribute in the initial elements, adding a loading attribute to the target element, and marking the attribute value of the loading attribute as delayed, so that the second browser uses the target plug-in to delay loading of the target element, specifically includes: Obtain the initial image element on the target page, filter out the target image elements that do not have an immediate loading attribute in the initial image elements, add a loading attribute to the target image elements, and mark the attribute value of the loading attribute as delayed, so that the second browser uses the target plug-in to delay loading of the target image elements.

4. The method according to claim 2, characterized in that: The obtaining of the initial element on the target page, screening the target elements that do not have an immediate loading attribute in the initial elements, adding a loading attribute to the target element, and marking the attribute value of the loading attribute as delayed, so that the second browser uses the target plug-in to delay loading of the target element, specifically includes: The initial frame element on the target page is obtained, target frame elements that do not have an immediate loading attribute are filtered out from the initial frame elements, a loading attribute is added to the target frame element, and the attribute value of the loading attribute is marked as delayed, so that the second browser uses the target plug-in to delay loading of the target frame element.

5. The method according to claim 2, characterized in that: The obtaining of the initial element on the target page specifically includes: Parsing the target page into a syntax tree using a hypertext markup language parser; The elements whose element names are pictures or frames in the syntax tree are traversed in a loop.

6. The method according to any one of claims 1 to 5, characterized in that: The obtaining of the browser array on which the website is running specifically includes: The browser operating environment of the website is obtained, and a matching browser array is obtained according to the browser operating environment of the website.

7. The method according to claim 6, characterized in that The step of obtaining a matching browser array according to the browser environment in which the website is running specifically includes: The browser operating environment of the website is obtained by using the second target library, and the second target library parses the target attribute of the first target file or the second target file in the browser operating environment to obtain a browser array matching the target attribute of the first target file or the second target file.

8. A page processing device, characterized in that: The device comprises: An acquisition module, used to acquire a target page and an array of browsers running on the website, and screen a first browser that does not support delayed loading and a second browser that supports delayed loading in the browser array; A first delay module is used to obtain the initial address attribute of the target element on the target page when the target page is loaded by the first browser, assign the attribute value of the initial address attribute of the target element to the target address attribute and delete the initial address attribute of the target element, add a delayed loading attribute to the class attribute of the target element, create a script tag for the target element, determine whether the delayed loading library is configured with a content distribution network address, and if so, configure the content distribution network address of the delayed loading library as the initial address attribute of the script tag, so that the first browser uses the target plug-in to delay loading the target element; wherein, if the delayed loading library is not configured with a content distribution network address, a default content distribution network address is configured as the initial address attribute of the script tag; A second delay module is used for adding a loading attribute to a target element on the target page and marking a property value of the loading attribute as delayed when the target page is loaded by the second browser, so that the second browser delays loading of the target element by using the target plug-in; When screening the first browser that does not support delayed loading and the second browser that supports delayed loading in the browser array, the acquisition module is specifically used to: use the first target library to determine whether each browser in the browser array supports delayed loading, and if so, mark all browsers as second browsers; if not, screen out the browsers that support delayed loading and the browsers that do not support delayed loading in the browser array, mark the browsers that support delayed loading as the second browser, and mark the browsers that do not support delayed loading as the first browser; wherein, when the browser array includes multiple types of browsers, the lowest version and / or the highest version of the same browser is judged for delayed loading.

9. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the page processing method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, which are used to implement the page processing method according to any one of claims 1 to 7 when executed by a processor.

11. A computer program product, characterized in that The computer program product comprises a computer program, which implements the page processing method according to any one of claims 1 to 7 when executed by a processor.