CN112214703B - Webpage loading method, webpage loading device, computer readable storage medium and computer equipment - Google Patents

Webpage loading method, webpage loading device, computer readable storage medium and computer equipment Download PDF

Info

Publication number
CN112214703B
CN112214703B CN201910619693.5A CN201910619693A CN112214703B CN 112214703 B CN112214703 B CN 112214703B CN 201910619693 A CN201910619693 A CN 201910619693A CN 112214703 B CN112214703 B CN 112214703B
Authority
CN
China
Prior art keywords
browser
characteristic
missing
webpage
script
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910619693.5A
Other languages
Chinese (zh)
Other versions
CN112214703A (en
Inventor
邱承运
刘恒兵
梁伟盛
何方舟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910619693.5A priority Critical patent/CN112214703B/en
Publication of CN112214703A publication Critical patent/CN112214703A/en
Application granted granted Critical
Publication of CN112214703B publication Critical patent/CN112214703B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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
    • G06F16/972Access to data in other repository systems, e.g. legacy data or dynamic Web page generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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
    • G06F16/986Document structures and storage, e.g. HTML extensions

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application relates to a webpage loading method, a webpage loading device, a computer readable storage medium and computer equipment, wherein the method comprises the following steps: when a webpage is loaded through a browser, detecting the characteristics of the browser locally, and acquiring a characteristic repair script file supporting the missing characteristics from a server according to the missing characteristics of the browser in the detection result. The loading feature patches the script file so that the browser normally loads the web page. According to the method, the characteristics of the browser are detected locally, the characteristics missing when the browser loads the webpage are detected, and the characteristic repair script file is correspondingly acquired from the server according to the missing characteristics. Then, the characteristic repair script file is loaded first to repair the missing characteristic of the browser, so that the repaired browser can be ensured to normally load the webpage. For the browser with partial missing characteristics or partial characteristics, redundant files cannot be loaded, so that waste of traffic and unnecessary waiting delay are avoided.

Description

Webpage loading method, webpage loading device, computer readable storage medium and computer equipment
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and apparatus for loading a web page, a computer readable storage medium, and a computer device.
Background
With the popularity of computers and the rapid development of internet technology, users increasingly acquire information by surfing the internet. For example, a web page is opened by a browser to access the internet to obtain information. However, the grammatical features of the javascript are supported differently by the browsers of different manufacturers, so that the same webpage may not operate normally in some browsers, and even a white screen appears. Therefore, a new webpage loading method is needed to be provided, so that faults in the webpage loading process are avoided, and normal access of the webpage is ensured.
Disclosure of Invention
Based on the above, it is necessary to provide a web page loading method, a device, a computer readable storage medium and a computer apparatus for solving the technical problems that the conventional web page loading method often fails and normal access of web pages cannot be guaranteed.
A web page loading method, comprising:
when a webpage is loaded through a browser, performing characteristic detection on the browser locally to obtain a detection result;
Acquiring a characteristic repair script file supporting the missing characteristic from a server according to the missing characteristic of the browser in the detection result;
and loading the characteristic patching script file so that the browser normally loads the webpage.
A web page loading apparatus, the apparatus comprising:
the characteristic detection module is used for carrying out characteristic detection on the browser locally to obtain a detection result when the webpage is loaded through the browser;
the characteristic repair script file acquisition module is used for acquiring a characteristic repair script file corresponding to the characteristics supporting the deletion from a server according to the characteristics of the browser deletion in the detection result;
and the webpage loading module is used for loading the characteristic patching script file so that the browser normally loads the webpage.
A computer readable storage medium storing a computer program which, when executed by a processor, causes the processor to perform the steps of the method as described above.
A computer device comprising a memory and a processor, the memory storing a computer program which, when executed by the processor, causes the processor to perform the steps of the method as described above.
According to the webpage loading method, the webpage loading device, the computer readable storage medium and the computer equipment, when the webpage is loaded through the browser, the characteristic detection is carried out on the browser locally to obtain a detection result, and according to the characteristics missing in the detection result of the browser, the characteristic repair script file supporting the missing characteristics is obtained from the server. The loading feature patches the script file so that the browser normally loads the web page. According to the traditional method, characteristic detection is not carried out on the browser locally, so that when a webpage is loaded through the browser, all characteristic repair script files are downloaded to repair missing characteristics of the browser regardless of whether the local browser lacks certain characteristics. Obviously, for the browser with part of the characteristics without deletion or part of the characteristics, redundant files are loaded, so that waste of traffic and unnecessary waiting delay are caused. The application detects the characteristic of the browser locally, detects the characteristic missing when the browser loads the webpage, and correspondingly acquires the characteristic repair script file supporting the missing characteristic from the server according to the missing characteristic. Then, the characteristic repair script file is loaded first to repair the missing characteristic of the browser, so that the repaired browser can be ensured to normally load the webpage. For the browser with partial missing characteristics or partial characteristics, redundant files cannot be loaded, so that waste of traffic and unnecessary waiting delay are avoided.
Drawings
FIG. 1 is an application environment diagram of a web page loading method in one embodiment;
FIG. 2 is a flowchart of a method for loading a web page according to an embodiment;
FIG. 3 is a flowchart illustrating a method for loading a web page according to another embodiment;
FIG. 4 is a flowchart of a method for loading a web page according to another embodiment;
FIG. 5 is a flowchart of the method for obtaining a characteristic repair script file supporting the missing characteristic from the server according to the missing characteristic of the browser in the detection result in FIG. 2;
FIG. 6 is a flowchart of a method for loading a web page according to an embodiment;
FIG. 7 is a block diagram illustrating a configuration of a web page loading apparatus according to one embodiment;
FIG. 8 is a block diagram illustrating an architecture of a web page loading apparatus according to another embodiment;
FIG. 9 is a block diagram of a computer device in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
FIG. 1 is an application environment diagram of a web page loading method in one embodiment. Referring to fig. 1, the web page loading method is applied to a web page loading system. The web page loading system includes a terminal 110 and a server 120. The terminal 110 and the server 120 are connected through a network. The terminal 110 may be a desktop terminal or a mobile terminal, and the mobile terminal may be at least one of a mobile phone, a tablet computer, a notebook computer, and the like. The server 120 may be implemented as a stand-alone server or as a server cluster composed of a plurality of servers. The webpage loading method comprises the following steps: when a webpage is loaded through a browser, characteristic detection is carried out on the browser locally to obtain a detection result. And acquiring a characteristic repair script file supporting the missing characteristic from the server according to the missing characteristic of the browser in the detection result. The loading feature patches the script file so that the browser normally loads the web page.
The JavaScript script code may be simply called JS script code, where the JS script code can only be run in a browser supporting these new language features and browser interfaces, otherwise, it is necessary to add a compatible code supporting these new language features and conversion of a compatible list of browser interfaces to the JS script code. These compatible codes may be referred to as patch files or patch files, i.e., polyfill files. Polyfill files refer to patches or compatible plug-ins, and can repair missing features of a browser, so that the repaired browser can normally load the webpage.
As shown in FIG. 2, in one embodiment, a web page loading method is provided. The present embodiment is mainly exemplified by the application of the method to the terminal 110 in fig. 1 described above, and the browser is installed in the terminal 110. Referring to fig. 2, the web page loading method specifically includes the following steps:
s202, when a webpage is loaded through a browser, detecting characteristics of the browser locally to obtain a detection result.
Because of the long browser version update period and the differences in implementation of different browser vendors, some new language features of JS (JavaScript) employed in web page development have failed to achieve complete support on all browsers. Therefore, when the webpage is loaded through the browser, the phenomenon of white screen appears in the browser because the browser does not support a certain characteristic, and normal use of a user is affected.
Therefore, when the webpage is loaded on the terminal through the browser, the characteristic detection is carried out on the browser locally to obtain a detection result. Specifically, it is determined by the developer of the web page which features of the browser to detect based on the features required to be used in the loading of the web page. The method mainly comprises the step of carrying out characteristic detection on the supporting degree of the browser on the characteristic of JavaScript locally to obtain a detection result. The detection result includes a property that the browser supports JavaScript, namely a missing property that the browser does not support JavaScript.
S204, according to the missing characteristics of the browser in the detection result, acquiring a characteristic repair script file supporting the missing characteristics from the server.
The developer of the webpage deploys the webpage on the server in advance, and loads the required characteristic patching script file, namely Polyfill file, in the browser. Polyfill files refer to patches or compatible plug-ins, and can repair missing features of a browser, so that the repaired browser can normally load the webpage. The server may be a CDN (Content Delivery Network ) server. The CDN is a content distribution network constructed on the network, and by means of the edge servers deployed in various places, a user can obtain required content nearby through load balancing, content distribution, scheduling and other functional modules of the center platform, network congestion is reduced, and user access response speed and hit rate are improved. The key technologies of CDNs mainly include content storage and distribution technologies. The CDN server is a cache server system formed by a plurality of servers and provides a function of accelerating an Internet server.
According to the characteristics of the browser missing in the detection result, the characteristic repair script file supporting the missing characteristics can be directly obtained from the CDN server.
S206, loading the characteristic patching script file so that the browser normally loads the webpage.
After the characteristic repair script file supporting the missing characteristic can be directly obtained from the CDN server and before the browser loads the service script of the webpage, the characteristic repair script file (Polyfill file) is firstly loaded to repair the missing characteristic of the browser, and then the service script of the webpage is loaded, so that the repaired browser can normally load the webpage.
In the traditional method, when a browser loads a webpage, all Polyfill files are automatically downloaded regardless of whether the browser needs the Polyfill files, and the Polyfill aggregate is introduced into a hypertext file (html file). Obviously, for a browser that does not need Polyfill files and a browser that only needs certain specific Polyfill files, downloading Polyfill files wastes traffic and delays latency.
In the embodiment of the application, the characteristics of the browser are detected locally, the characteristics missing when the browser loads the webpage are detected, and the characteristic repair script file supporting the missing characteristics is correspondingly acquired from the server according to the missing characteristics. Then, the characteristic repair script file is loaded first to repair the missing characteristic of the browser, so that the repaired browser can be ensured to normally load the webpage. For the browser with partial missing characteristics or partial characteristics, redundant files cannot be loaded, so that waste of traffic and unnecessary waiting delay are avoided.
In one embodiment, as shown in fig. 3, a web page loading method is provided, and further includes:
adding a script for detecting the characteristics of the browser into a hypertext document of a webpage in advance;
when a webpage is loaded through a browser, performing characteristic detection on the browser locally to obtain a detection result, wherein the detection result comprises the following steps:
when a webpage is loaded through a browser, a hypertext file is locally operated to load a script for characteristic detection, and the characteristic detection is carried out on the browser to obtain a detection result.
Referring to FIG. 3, a flowchart of another method for loading a web page is shown. The method for loading the webpage comprises the following steps:
step S302, adding a script for detecting the characteristics of the browser into a hypertext document of a webpage in advance;
step S304, when the webpage is loaded through the browser, the hypertext file is locally operated to load the script for characteristic detection, and the characteristic detection is carried out on the browser to obtain a detection result.
Step S306, according to the missing characteristics of the browser in the detection result, a characteristic repair script file supporting the missing characteristics is obtained from the server;
step S308, the characteristic patching script file is loaded so that the browser normally loads the webpage.
Specifically, a webpage developer adds a script for detecting characteristics of a browser into a hypertext document (html document) of a webpage in advance, so that when the webpage is loaded through the browser, after the html document is downloaded by the browser, the html document is firstly operated locally to load the script for detecting characteristics, and the characteristics of the browser are detected to obtain a detection result. The script for performing the characteristic detection is to obtain whether the global object of the browser has a certain specific characteristic or not by performing the characteristic detection on the global object of the local browser. Because the script for detecting the characteristics is added to the hypertext file (html file) of the web page by the web page developer, the web page developer can set the script for detecting the characteristics according to different characteristics required by different web page loads, so that the script for detecting the characteristics added to the html file of a certain web page only needs to detect the characteristics required by the web page loads, and the missing characteristics detected by the script for detecting the characteristics in the html file of each web page can be different. The webpage developer pertinently develops the characteristic detection script and adds the characteristic detection script to the html file of the webpage, so that the detection efficiency is improved and the resources are saved.
The detection result includes two cases, one is that the browser supports all the detected characteristics, and the other is that the browser does not support part of the detected characteristics or all the detected characteristics, and the unsupported characteristics are missing characteristics. And acquiring a characteristic repair script file supporting the missing characteristic from the server according to the missing characteristic of the browser in the detection result. Because the server stores the characteristic patching script file (Polyfill file) corresponding to all the characteristics detected by the script for detecting the characteristics added in the html file of the webpage in advance, the Polyfill file can be directly obtained according to the missing characteristics to carry out characteristic patching on the browser. Polyfill files may be files that patch one or more missing features of a browser. The characteristic patching mode can be that the characteristic patching script file is loaded by the browser to finish the patching of the real characteristic of the browser, and the browser after the patching can normally load the webpage.
In the embodiment of the application, the script for detecting the characteristics of the browser is added to the hypertext file of the webpage in advance, so that when the browser loads the webpage, the detection of the missing characteristics of the browser can be finished locally, the request to the server for obtaining the version and other information of the browser is not needed, and the missing characteristics are determined from the version and other information. Obviously, the method for locally detecting the missing characteristic is faster and more convenient without a remote server, so that the waiting delay for waiting for the server to return to the missing characteristic is reduced, and the waste of flow is also reduced.
In one embodiment, when loading a web page through a browser, running a hypertext document locally to load a script for performing feature detection, performing feature detection on the browser to obtain a detection result, including:
when a webpage is loaded through a browser, a hypertext file is locally operated to load a script for characteristic detection, and whether a global object of the browser has preset characteristics is checked;
if the judgment result is that the browser does not have the preset characteristic, obtaining that the browser lacks the preset characteristic;
if the judgment result is that the browser has the preset characteristics, detecting whether the calling mode of the preset characteristics is correct, and if the calling mode of the preset characteristics is incorrect, obtaining that the browser lacks the preset characteristics;
if the global object of the browser is correct, the global object of the browser is obtained to have the preset characteristic.
Specifically, the global object is a predefined object, and is used as a global function and a placeholder of a global attribute of the JavaScript. All other predefined objects, functions and properties can be accessed by using the global object. The global object is not an attribute of any object, so the global object has no name. Here the global object of the browser is a window object. The preset characteristic refers to a characteristic that a characteristic detection script added to an html file of a webpage by a webpage developer detects a browser, and the preset characteristic is generally a characteristic required by loading the webpage. For example, if a certain web page normally loads a feature that a global object window of a browser has a window. Program, a hypertext file is locally run to load a script for performing feature detection, and whether the global object of the browser has the feature of window. Map is checked. And detecting whether the window map is undefined or not, if so, obtaining that the global object of the browser does not have the characteristic of the window map, wherein the window map is the missing characteristic. If the window map is the defined one, the feature that the global object of the browser has the window map is obtained, and then whether the calling mode of the feature of the window map is correct is further checked, if not, the feature that the browser lacks the window map is obtained; if the feature is correct, the global object of the browser is obtained to have the feature of window. For example, it is checked whether the call mode newMap of the feature of window.map (i.e., [ 'key', true ] ]) throws an exception to check how supported the feature of window.map is by the browser.
In the embodiment of the application, when the characteristic detection script detects the characteristics of the browser, only preset characteristics, which are generally required by the loading of the webpage, are detected. Therefore, the characteristics required by loading the webpage can be detected in a targeted manner for the browser, so that the detection efficiency is improved. In the detection process, whether the global object of the browser has the preset characteristic is detected, and if the global object of the browser has the preset characteristic, whether the calling mode of the preset characteristic is correct is further detected, so that the global object of the browser has the preset characteristic can be obtained. Meanwhile, detection is carried out locally, so that the defect characteristic cannot be accurately obtained due to some tampering in the process of obtaining the defect characteristic on the server in the traditional method is avoided. In summary, in the embodiment of the application, accurate and comprehensive detection can be performed, and the accuracy of the detection result is ensured.
In one embodiment, after obtaining that the global object of the browser has the preset characteristic, the method further includes: and loading the business script of the webpage so that the browser normally loads the webpage.
As shown in fig. 4, a web page loading method is provided, which includes the following steps:
Step S402, adding a script for detecting the characteristics of the browser into a hypertext document of a webpage in advance;
step S404, when loading a webpage through a browser, running a hypertext file locally to load a script for characteristic detection, and carrying out characteristic detection on the browser to obtain a detection result;
step S406, if the global object of the browser has the preset characteristic, loading the service script of the webpage so that the browser normally loads the webpage.
Specifically, a webpage developer adds a script for detecting characteristics of a browser into a hypertext document (html document) of a webpage in advance, so that when the webpage is loaded through the browser, after the html document is downloaded by the browser, the html document is firstly operated locally to load the script for detecting characteristics, and the characteristics of the browser are detected to obtain a detection result. The detection result is that the browser supports all the detected characteristics, and the browser can be ensured to normally load the webpage without acquiring the Polyfill file and directly loading the service script of the webpage. The html file not only contains the script for detecting the characteristics, but also contains the service script of the webpage.
In the traditional method, when a browser loads a webpage, all Polyfill files are automatically downloaded regardless of whether the browser needs the Polyfill files, and the Polyfill aggregate is introduced into a hypertext file (html file). Obviously, for a browser which does not need the Polyfill file, downloading the Polyfill file obviously wastes traffic and delays waiting time. For example, when a local browser loads a web page, the user who may need to download the Polyfill files only occupies 3%, if all the Polyfill files are automatically downloaded regardless of whether the browser needs the Polyfill files, 97% of users have downloaded Polyfill files more. Obviously, this causes a great waste of resources.
In the embodiment of the application, the situation that the local browser does not lack the characteristics required by loading a certain webpage is detected, so that the normal loading of the webpage by the browser can be ensured without acquiring the Polyfill file and directly loading the service script of the webpage. Compared with the traditional method, the flow waste is greatly reduced, and the waiting time is also reduced.
In one embodiment, as shown in fig. 5, step S204, according to the characteristics of the browser missing in the detection result, obtains a characteristic repair script file supporting the missing characteristics from the server, including:
step S204a, according to the missing characteristic of the browser in the detection result, a storage address of the characteristic patching script file supporting the missing characteristic on the server is generated.
Step S204b, the characteristic repair script file is obtained from the server according to the storage address.
Because the developer of the webpage deploys the characteristic patching script file, namely the Polyfill file, which is needed to be used by loading the webpage in the browser on the server in advance, the Polyfill file is stored on the server and corresponds to a storage address. The characteristic patching script file can generate a storage address of the characteristic patching script file supporting the missing characteristic on the server according to the missing characteristic of the browser in the detection result. For example, when the feature of the browser missing is window map in the detection result, the feature patching script file may generate a storage address of the feature patching script file map.js supporting the missing feature on the server, such as http:// xxxx/map.js, according to the window map of the browser missing. Where xxxx is the address of a server. According to http:// xxxx/map.js, the characteristic repair script file map.js can be obtained from the server. And then the browser loading characteristic repair script file map.js can repair the window.map characteristic missing by the browser, and the repaired browser can normally load the service codes in the htlm file, so that the browser normally loads the webpage. The missing feature may be one or more, and is not limited herein.
In the embodiment of the application, the characteristic repair script file not only can locally detect the missing characteristic of the browser, but also can generate the storage address of the characteristic repair script file supporting the missing characteristic on the server according to the missing characteristic of the browser in the detection result. Therefore, the browser can acquire the characteristic repair script file corresponding to the missing characteristic from the server through the storage address, and download the characteristic repair script file to the local, and then the browser can repair the missing characteristic of the browser by loading the characteristic repair script file, and the browser after repair can normally load the service code in the webpage html file, so that the browser normally loads the webpage.
In one embodiment, step S204, according to the missing feature of the browser in the detection result, obtains a feature patch script file supporting the missing feature from the server, and further includes:
when the characteristics of the browser missing in the detection result are two or more, generating a splicing address of the characteristic repair script file supporting the characteristics of the missing on the server according to the characteristics of the browser missing; and acquiring the spliced characteristic repair script file from the server according to the splicing address.
Specifically, when the missing feature of the browser in the detection result is one, an address of the feature patch script file supporting the missing feature on the server is generated according to the one feature of the browser. And acquiring the characteristic repair script file corresponding to the missing characteristic from the server according to the address.
And when the characteristics of the browser missing in the detection result are two or more, two or more characteristic repair script files are corresponding. And generating splicing addresses of the corresponding two or more characteristic repair script files on the server according to the missing characteristics of the browser. The splicing address splices the addresses of all the required characteristic repair script files, and all the required characteristic repair script files can be obtained by accessing the splicing address once. The problem that the traditional non-spliced address only acquires one characteristic repair script file through one address access is avoided, so that address access to a server needs to be carried out for many times, time resource waste is caused, and time delay of loading a webpage by a browser is prolonged.
In the embodiment of the application, when the characteristics of the browser missing in the detection result are two or more, the addresses of the characteristic repair script files corresponding to all the missing characteristics on the server are spliced to obtain spliced addresses. Therefore, the browser only needs to send an address access request to the server once, and all the characteristic repair script files, namely a plurality of characteristic repair script files, can be obtained through the spliced address. Therefore, the waste of time resources is greatly reduced, and the time delay of loading the webpage by the browser is further reduced.
In one embodiment, step S206, loading the property patch script file to enable the browser to normally load the web page includes:
operating a characteristic repair script file in an asynchronous script loading mode;
and running the service script of the webpage so that the browser normally loads the webpage.
Specifically, the asynchronous script loading mode is called non-blocking loading, that is, the browser can continue to process the subsequent page while downloading and executing the JS file. Asynchronous loading mainly has three ways, namely a first way Script DOM Element, but the loading way prevents the triggering of an onload event before the execution is finished, and now codes of many pages also execute additional rendering work when the onload is finished, so that the initialization processing of partial pages is blocked. The second asynchronous loading method is to put the script inserting method into a function and then to execute the script inserting method into the window's onload method, thus solving the problem of blocking the onload event triggering. The third is other methods, which include many asynchronous loading methods due to JavaScript dynamics: XHR Injection, XHR Eval, script in Iframe, script refer attribute, document.
The feature patch script file (Polyfill file) is introduced into the browser running environment by means of an asynchronous loading script, such as document. Then, when running the business script of the web page, the browser can normally load the web page.
In the embodiment of the application, after the browser acquires the Polyfill files required by the webpage loading from the server, the Polyfill files are operated in an asynchronous loading script mode, and the Polyfill files are introduced into a browser operation environment and are executed before the service script. Then, when running the business script of the web page, the browser can normally load the web page. The browser cannot be blocked from analyzing the html file in an asynchronous loading mode, and the polyaill file is loaded while analyzing, so that the webpage rendering can be accelerated.
Fig. 6 is a flowchart of a web page loading method in one embodiment. The webpage loading method specifically comprises the following steps:
step S602, adding a script for detecting the characteristics of the browser into a hypertext document of a webpage in advance;
step S604, when loading a webpage through a browser, running a hypertext file locally to load a script for characteristic detection, and checking whether a global object of the browser has preset characteristics;
Step S606, if the judgment result is that the browser does not have the preset characteristic, the browser is obtained to lack the preset characteristic;
step S608, if the judgment result is that the browser has the preset characteristics, further detecting whether the calling mode of the preset characteristics is correct, and if not, entering step S606 to obtain that the browser lacks the preset characteristics;
step S610, if the browser is right, obtaining that the global object of the browser has preset characteristics, and loading the business script of the webpage so that the browser normally loads the webpage;
step S612, when the characteristics of the browser missing in the detection result are two or more, generating a splicing address of the characteristic repair script file supporting the missing characteristics on the server according to the characteristics of the browser missing;
step S614, the spliced characteristic repair script file is obtained from the server according to the splicing address.
Step S616, the characteristic repair script file is operated in a mode of asynchronously loading scripts, and the Polyfill file is introduced into a browser operation environment and is executed before the service scripts;
in step S618, the service script of the web page is run to make the browser load the web page normally.
The Polyfill.io scheme in the traditional method is a scheme for judging the missing characteristic of the browser based on the analysis of a user-agent in an http request header. Wherein, browser identifier (User-Agent) refers to an identifier describing information such as name, version and operating system of the current browser of the User. The browser identifier indicates new language properties and browser interfaces that the browser used by the user can support.
The browser analyzes the information about the browser version and the kernel type in the user-agent field through an http request sent to the polyfill.io server to judge which characteristics are missing in the current browser, so that js scripts with the missing characteristics are returned to the browser. The characteristic judgment of each browser needs to send an http request to the Polyfill.io server, and obviously, the http request is a waste of traffic for most browser users without characteristic loss in the market. Meanwhile, each time of page initialization needs to wait for the return of the Polyfill characteristic judgment request, and the loading time of the page is increased. And the obtained result is inaccurate by using the user-agent, because the content of the user-agent in the http request header can be modified, the browser also can customize the user-agent, so that the user-agent cannot always be identified by the time Polyfill.io server, and the browser characteristic judgment failure can be caused.
Table 1 is a data table of results of web page loading by the browser through the Polyfill loading method based on local characteristic detection and the Polyfill.io scheme in the conventional method.
The Polyfill loading method based on local characteristic detection is better than the Polyfill. Io scheme in terms of file loading time, loading success rate and characteristic judging success rate.
In the embodiment of the application, firstly, the script for detecting the characteristics of the browser is added to the hypertext file of the webpage in advance, so that when the browser loads the webpage, the detection of the missing characteristics of the browser can be finished locally, the request to the server for obtaining the information of the version and the like of the browser is not needed, and the missing characteristics are determined from the information of the version and the like.
Secondly, when the characteristic detection script detects the characteristics of the browser, only preset characteristics, which are generally required by the loading of the webpage, need to be detected. Therefore, the characteristics required by loading the webpage can be detected in a targeted manner for the browser, so that the detection efficiency is improved. Meanwhile, detection is carried out locally, so that the defect characteristic cannot be accurately obtained due to some tampering in the process of obtaining the defect characteristic on the server in the traditional method is avoided.
Finally, by splicing the addresses, the browser only needs to send an address access request to the server once, and a plurality of characteristic repair script files can be obtained through the spliced addresses. And the browser runs the Polyfill files in an asynchronous script loading mode, and introduces the Polyfill files into a browser running environment and executes the Polyfill files before the business script. Then, when running the business script of the web page, the browser can normally load the web page. The whole process greatly reduces the waste of time resources, and further reduces the time delay of loading the webpage by the browser.
FIG. 6 is a flowchart of a method for loading a web page according to an embodiment. It should be understood that, although the steps in the flowchart of fig. 6 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in fig. 6 may include multiple sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, nor do the order in which the sub-steps or stages are performed necessarily performed in sequence, but may be performed alternately or alternately with at least a portion of the sub-steps or stages of other steps or other steps.
In one embodiment, as shown in fig. 7, there is provided a web page loading apparatus 700, including: a property detection module 702, a property patch script file acquisition module 704, and a web page loading module 706. Wherein,
the characteristic detection module 702 is configured to perform characteristic detection on the browser locally to obtain a detection result when the webpage is loaded through the browser;
The characteristic repair script file obtaining module 704 is configured to obtain, from the server, a characteristic repair script file corresponding to a characteristic supporting the deletion according to the characteristic missing by the browser in the detection result;
the web page loading module 706 is configured to load the property patch script file so that the browser normally loads the web page.
In one embodiment, as shown in fig. 8, a web page loading device 700 is provided, further including: a script adding module 708 for detecting characteristics, configured to add a script for detecting characteristics of a browser to a hypertext document of a web page in advance;
the feature detection module 702 is further configured to, when a web page is loaded through a browser, locally run a hypertext file to load a script for performing feature detection, and perform feature detection on the browser to obtain a detection result.
In one embodiment, the feature detection module 702 is further configured to, when loading a web page through the browser, locally run a hypertext document to load a script for feature detection, and check whether a global object of the browser has a preset feature;
if the judgment result is that the browser does not have the preset characteristic, obtaining that the browser lacks the preset characteristic;
if the judgment result is that the browser has the preset characteristics, detecting whether the calling mode of the preset characteristics is correct, and if the calling mode of the preset characteristics is incorrect, obtaining that the browser lacks the preset characteristics;
If the global object of the browser is correct, the global object of the browser is obtained to have the preset characteristic.
In one embodiment, the web page loading module 706 is configured to load a service script of a web page to enable the browser to normally load the web page.
In one embodiment, the characteristic repair script file obtaining module 704 is further configured to generate, according to the characteristics of the browser missing in the detection result, a storage address of the characteristic repair script file supporting the missing characteristics on the server; and acquiring the characteristic patching script file from the server according to the storage address.
In one embodiment, the characteristic repair script file obtaining module 704 is further configured to generate, when the characteristics of the browser missing in the detection result are two or more, a splicing address of the characteristic repair script file supporting the missing characteristics on the server according to the characteristics of the browser missing; and acquiring the spliced characteristic repair script file from the server according to the splicing address.
In one embodiment, the webpage loading module 706 is further configured to run a property patch script file by asynchronously loading the script; and running the service script of the webpage so that the browser normally loads the webpage.
FIG. 9 illustrates an internal block diagram of a computer device in one embodiment. The computer device may be specifically the terminal 110 of fig. 1. As shown in fig. 9, the computer device includes a processor, a memory, a network interface, an input device, a display screen, a camera, a sound collection device, and a speaker connected by a system bus. The memory includes a nonvolatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system, and may also store a computer program that, when executed by a processor, causes the processor to implement the above-described web page loading method. The internal memory may also store a computer program that, when executed by the processor, causes the processor to perform the web page loading method described above. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, the input device of the computer equipment can be a touch layer covered on the display screen, can also be keys, a track ball or a touch pad arranged on the shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by persons skilled in the art that the architecture shown in fig. 9 is merely a block diagram of some of the architecture relevant to the present inventive arrangements and is not limiting as to the computer device to which the present inventive arrangements are applicable, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In one embodiment, the web page loading apparatus provided by the present application may be implemented in the form of a computer program, which may be executed on a computer device as shown in fig. 9. The memory of the computer device may store various program modules that make up the web page loading apparatus, such as the feature detection module 702, the feature patch script file acquisition module 704, and the web page loading module 706 shown in fig. 7. The computer program constituted by the respective program modules causes the processor to execute the steps in the web page loading method of the respective embodiments of the present application described in the present specification.
For example, the computer apparatus shown in fig. 9 may perform step S202 through the characteristic detection module 702 in the web page loading device shown in fig. 7. The computer device may perform step S204 through the property patch script file acquisition module 704. The computer device may execute step S206 through the web page loading module 706.
In one embodiment, a computer device is provided that includes a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the above-described web page loading method. The steps of the web page loading method herein may be the steps in the web page loading method of the above embodiments.
In one embodiment, a computer readable storage medium is provided, storing a computer program which, when executed by a processor, causes the processor to perform the steps of the above-described web page loading method. The steps of the web page loading method herein may be the steps in the web page loading method of the above embodiments.
Those skilled in the art will appreciate that the processes implementing all or part of the methods of the above embodiments may be implemented by a computer program for instructing relevant hardware, and the program may be stored in a non-volatile computer readable storage medium, and the program may include the processes of the embodiments of the methods as above when executed. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
The technical features of the above-described embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above-described embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of protection of the present application is to be determined by the appended claims.

Claims (16)

1. A web page loading method, comprising:
adding a script for detecting the characteristics of the browser into a hypertext document of a webpage in advance;
when a webpage is loaded through the browser, running the hypertext file locally to load the script for performing characteristic detection, and checking whether a global object of the browser has preset characteristics;
If the judgment result is that the browser does not have the preset characteristic, the browser is obtained to lack the preset characteristic;
if the judgment result shows that the browser has the preset characteristics, detecting whether a calling mode of the preset characteristics is correct, and if the calling mode of the preset characteristics is incorrect, obtaining that the browser lacks the preset characteristics;
if the global object of the browser is correct, obtaining that the global object of the browser has the preset characteristic;
according to the missing characteristics of the browser, acquiring a characteristic repair script file supporting the missing characteristics from a server;
and loading the characteristic patching script file so that the browser normally loads the webpage.
2. The method of claim 1, wherein after deriving that the global object of the browser has the preset property, the method further comprises:
and loading the service script of the webpage so that the browser normally loads the webpage.
3. The method of claim 1, wherein the browser missing feature obtains a feature patch script file from a server that supports the missing feature, comprising:
generating a storage address of a characteristic repair script file supporting the missing characteristic on a server according to the missing characteristic of the browser;
And acquiring the characteristic repair script file from the server according to the storage address.
4. The method of claim 1, wherein the obtaining, from the server, a property patch script file supporting the missing property according to the missing property of the browser, further comprises:
when the characteristics of the browser deletion are two or more, generating a splicing address of the characteristic repair script file supporting the characteristics of the deletion on a server according to the characteristics of the browser deletion;
and acquiring the spliced characteristic repair script file from the server according to the splicing address.
5. The method according to claim 4, wherein when the characteristics of the browser are missing, generating a splice address of a characteristic patching script file supporting the missing characteristics on a server according to the characteristics of the browser missing, comprises:
when the characteristics of the browser deletion are two or more, the addresses of the characteristic repair files corresponding to the characteristics of the browser deletion on the server are spliced to obtain spliced addresses.
6. The method of claim 1, wherein loading the property patch script file to cause the browser to normally load the web page comprises:
Loading the characteristic repairing script file to repair the missing characteristic of the browser;
and loading the business script of the webpage so that the repaired browser normally loads the webpage.
7. The method of claim 1, wherein loading the property patch script file to cause the browser to normally load the web page comprises:
operating the characteristic repair script file in an asynchronous loading script mode;
and running the service script of the webpage so that the browser normally loads the webpage.
8. A web page loading device, the device comprising:
the script adding module for characteristic detection is used for adding a script for characteristic detection of the browser into a hypertext file of the webpage in advance;
the characteristic detection module is used for locally running the hypertext file to load the script for characteristic detection when the webpage is loaded through the browser, and checking whether the global object of the browser has preset characteristics or not; if the judgment result is that the browser does not have the preset characteristic, the browser is obtained to lack the preset characteristic; if the judgment result shows that the browser has the preset characteristics, detecting whether a calling mode of the preset characteristics is correct, if not, obtaining that the browser lacks the preset characteristics, and if so, obtaining that the global object of the browser has the preset characteristics;
The characteristic repair script file acquisition module is used for acquiring a characteristic repair script file corresponding to the characteristics supporting the deletion from a server according to the characteristics of the deletion of the browser;
and the webpage loading module is used for loading the characteristic patching script file so that the browser normally loads the webpage.
9. The apparatus of claim 8, wherein the web page loading module is further configured to load a service script of the web page to enable the browser to normally load the web page after the global object of the browser is derived to have the preset characteristic.
10. The apparatus of claim 8, wherein the property patch script file acquisition module is further configured to generate a storage address on a server of a property patch script file supporting the missing property according to the missing property of the browser; and acquiring the characteristic repair script file from the server according to the storage address.
11. The apparatus of claim 8, wherein the property patch script file obtaining module is further configured to generate, when the missing properties of the browser are two or more, a splice address of a property patch script file supporting the missing properties on a server according to the missing properties of the browser; and acquiring the spliced characteristic repair script file from the server according to the splicing address.
12. The apparatus of claim 11, wherein the property patch script file obtaining module is further configured to splice addresses of property patch files corresponding to the missing features of the browser on a server to obtain spliced addresses when the missing features of the browser are two or more.
13. The apparatus of claim 8, wherein the web page loading module is further configured to load the property patch script file to patch the missing property of the browser; and loading the business script of the webpage so that the repaired browser normally loads the webpage.
14. The apparatus of claim 8, wherein the web page loading module is further configured to run the property patch script file by asynchronously loading scripts; and running the service script of the webpage so that the browser normally loads the webpage.
15. A computer readable storage medium storing a computer program which, when executed by a processor, causes the processor to perform the steps of the method of any one of claims 1 to 7.
16. A computer device comprising a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the method of any of claims 1 to 7.
CN201910619693.5A 2019-07-10 2019-07-10 Webpage loading method, webpage loading device, computer readable storage medium and computer equipment Active CN112214703B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910619693.5A CN112214703B (en) 2019-07-10 2019-07-10 Webpage loading method, webpage loading device, computer readable storage medium and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910619693.5A CN112214703B (en) 2019-07-10 2019-07-10 Webpage loading method, webpage loading device, computer readable storage medium and computer equipment

Publications (2)

Publication Number Publication Date
CN112214703A CN112214703A (en) 2021-01-12
CN112214703B true CN112214703B (en) 2023-11-07

Family

ID=74047398

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910619693.5A Active CN112214703B (en) 2019-07-10 2019-07-10 Webpage loading method, webpage loading device, computer readable storage medium and computer equipment

Country Status (1)

Country Link
CN (1) CN112214703B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112698879A (en) * 2020-12-25 2021-04-23 维沃移动通信有限公司 Method and device for loading source file

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110161401A1 (en) * 2009-12-30 2011-06-30 Teradata Us, Inc. Dynamic resource management
CN105955980A (en) * 2013-05-31 2016-09-21 北京奇虎科技有限公司 File download device and method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110161401A1 (en) * 2009-12-30 2011-06-30 Teradata Us, Inc. Dynamic resource management
CN105955980A (en) * 2013-05-31 2016-09-21 北京奇虎科技有限公司 File download device and method

Also Published As

Publication number Publication date
CN112214703A (en) 2021-01-12

Similar Documents

Publication Publication Date Title
CN107783795B (en) Application program starting method and device, computer equipment and storage medium
CN109299015B (en) Software testing method, device and system
CN108108219B (en) Application program running method and device, computer equipment and storage medium
CN107707561B (en) Penetration testing method and device
CN110365724B (en) Task processing method and device and electronic equipment
CN109190067B (en) Browser input box display method and device, computer equipment and storage medium
CN108418797B (en) Webpage access method and device, computer equipment and storage medium
CN112181532B (en) Page resource loading method and device, electronic equipment and readable storage medium
CN110781070A (en) Big data test verification method and device, computer equipment and storage medium
CN112947945B (en) Multi-type application release method and device, computer equipment and storage medium
CN111431767B (en) Multi-browser resource synchronization method and device, computer equipment and storage medium
CN112214703B (en) Webpage loading method, webpage loading device, computer readable storage medium and computer equipment
CN112650689A (en) Test method, test device, electronic equipment and storage medium
CN112035113A (en) Navigation bar loading method, device, equipment and medium of H5 page
CN111026988A (en) Page loading method, device and system and computer equipment
CN112446723A (en) Method, computer-readable storage medium, and apparatus for determining user invitation relationship
CN107203714B (en) Configuration method and device of data verification file
CN110858238A (en) Data processing method and device
CN110061864B (en) Method and system for automatically verifying domain name configuration
CN111177624B (en) Website front-end and back-end communication method, device, computer equipment and storage medium
CN109324822B (en) PWA (public warning assistant) item detection method, computer-readable storage medium and terminal device
CN112559938A (en) Electronic seal file generation method and device, computer equipment and storage medium
CN112783759B (en) White box test task execution method and device, storage medium and computer equipment
CN113326080B (en) H5 page loading method, device, equipment and storage medium
CN112560035B (en) Application detection method, device, equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant