Browser running method and device, computer equipment and readable storage medium
By detecting the browser version and loading the version code package that supports the minimum syntax standard, the resource consumption problem caused by browser version inconsistency is solved, resulting in higher execution performance and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- KANG JIAN INFORMATION TECH (SHENZHEN) CO LTD
- Filing Date
- 2022-11-15
- Publication Date
- 2026-07-03
AI Technical Summary
When browsers run new features, version inconsistencies cause them to load extra code, consuming a lot of resources and preventing them from utilizing native support for the new features, resulting in poor performance.
By detecting the browser level, matching and loading the code package that meets the minimum syntax standard supported by the target browser, the browser can directly interpret and execute the code, avoiding the use of Babel tools as an intermediate layer.
It improves browser performance, reduces unnecessary code loading, and enhances the user experience.
Smart Images

Figure CN115878928B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of front-end development and digital medical technology, and in particular to a method, apparatus, computer device and readable storage medium for operating a browser. Background Technology
[0002] In recent years, front-end development technologies have made rapid progress, and the JavaScript (an interpreted scripting language) language standard has been constantly updated, with more and more new features being natively supported by browsers, such as Classes, Promises (a technology for asynchronous computation), and ESM (ES Modules, an ECMAScript standard for handling modules). With the rise of digital healthcare technology, browsers supporting functions such as disease-aided diagnosis, health management, and remote consultations are emerging in large numbers. Developers continuously develop new features for browsers during normal operation to diversify their functionality and meet different user needs. Because users have varying browser versions, it's necessary to ensure compatibility with older browsers, requiring tools to enable browsers to run new features correctly. Currently, a commonly used tool is Babel (a JavaScript compiler). Babel is a tool for the latest JavaScript language features; it's a transpiler or compiler. Using Babel, developers can use ECMAScript 6 and above features and convert them into equivalent JavaScript for older versions, allowing browsers to interpret and run them.
[0003] In related technologies, when using the Babel tool, if the source code provided by the developer uses language features of ECMAScript 6 or higher, the source code can first be converted to ECMAScript 5 syntax using the Babel tool, and the Babel-polyfill module of the Babel tool can be imported to provide APIs (Application Program Interfaces) that are not supported by the browser, so that the browser can interpret and run the source code normally.
[0004] In the process of developing this application, the applicant discovered that the relevant technology has at least the following problems:
[0005] Because it is sometimes impossible to determine whether the browser version is the latest, the source code package provided by the developer includes the Babel tool. Some newer browsers also need to load extra code to make the Babel tool run, which causes the browser to consume a lot of extra loading resources at runtime. The Babel tool needs to be used as an intermediate layer to execute new features, and it cannot take advantage of its own native support for new features, resulting in poor execution performance. Summary of the Invention
[0006] In view of this, this application provides a browser operation method, apparatus, computer device, and readable storage medium, the main purpose of which is to solve the problem that current browsers consume a lot of additional loading resources during runtime, require the Babel tool as an intermediate layer to execute new features, cannot utilize their own native support for new features, and have poor execution performance.
[0007] According to a first aspect of this application, a method for operating a browser is provided, the method comprising:
[0008] When a request to run a browser is detected, the browser to be run is taken as the target browser, and the browser level of the target browser is matched.
[0009] Obtain the browser level associated level code package, wherein the code included in the level code package is compiled using the minimum syntax standard supported by the target browser;
[0010] Control the target browser to execute the level code package so that the target browser can run successfully.
[0011] Optionally, before determining the target browser and matching its browser class when a browser request is detected, the method further includes:
[0012] In response to a level setting request, obtain the level mapping relationship document carried in the level setting request;
[0013] Identify multiple preset levels included in the level mapping document, and construct a grammatical standard range for each of the multiple preset levels based on the level mapping document;
[0014] Each preset level is labeled using the grammar standard range corresponding to each preset level, and the labeled preset levels are stored.
[0015] Optionally, constructing a grammatical standard range for each of the plurality of preset levels based on the level mapping document includes:
[0016] For each of the plurality of preset levels, at least one grammatical standard that has a mapping relationship with the preset level is identified in the level mapping relationship document;
[0017] Extract the highest and lowest grammatical standards from the at least one grammatical standard;
[0018] Using the highest grammatical standard and the lowest grammatical standard as the endpoints, construct the preset level of grammatical standard interval.
[0019] Optionally, after annotating each preset level with the syntax standard range corresponding to each preset level and storing the annotated multiple preset levels, the method further includes:
[0020] When a function configuration request is received, the source code to be run carried in the function configuration request is obtained;
[0021] For each of the plurality of preset levels, obtain the grammatical standard range marked by the preset level, and extract the lowest grammatical standard from the two endpoints of the grammatical standard range.
[0022] The language compilation tool is invoked to compile the source code to be run according to the minimum syntax standard to obtain a first-level code package, wherein the syntax of the code included in the first-level code package is the minimum syntax standard;
[0023] The level code package is associated with and stored with the preset level.
[0024] Optionally, the calling language compilation tool compiles the source code to be run according to the lowest level syntax standard to obtain a first-level code package, including:
[0025] Invoke the language compilation tool and determine the target attribute field within the language compilation tool;
[0026] The Target attribute field is assigned a value using the lowest level syntax standard, and the language compilation tool is used to compile the source code to be run based on the assigned value.
[0027] The code package output by the language compiler is obtained as the level code package.
[0028] Optionally, the browser level matching the target browser includes:
[0029] Query the minimum syntax standard supported by the target browser, and use the minimum syntax standard as the target syntax standard;
[0030] Obtain multiple preset levels and the syntax standard range marked for each preset level to obtain multiple syntax standard ranges;
[0031] Determine the target grammar standard interval to which the target grammar standard belongs among the multiple grammar standard intervals, and query the target preset level marked by the target grammar standard interval, and use the target preset level as the browser level of the target browser.
[0032] Optionally, obtaining the browser level-associated level code package includes:
[0033] The current startup stage is continuously monitored during the startup process of the target browser;
[0034] When the current startup phase indicates that browser resources are to be loaded, query the level code package that is related to the browser level;
[0035] Control the target browser to load the level code package at the current startup stage.
[0036] According to a second aspect of this application, a browser operating device is provided, the device comprising:
[0037] The matching module is used to, when a request to run a browser is detected, take the requested browser as the target browser and match the browser level of the target browser;
[0038] The acquisition module is used to acquire the browser level associated level code package, wherein the code included in the level code package is compiled using the minimum syntax standard supported by the target browser;
[0039] The runtime module is used to control the target browser to execute the level code package so that the target browser can run successfully.
[0040] Optionally, the device further includes:
[0041] The acquisition module is also used to acquire the level mapping relationship document carried by the level setting request in response to the level setting request;
[0042] A construction module is used to identify multiple preset levels included in the level mapping relationship document, and to construct a grammatical standard range for each of the multiple preset levels based on the level mapping relationship document;
[0043] The storage module is used to annotate each preset level using the syntax standard range corresponding to each preset level, and to store the annotated preset levels.
[0044] Optionally, the construction module is configured to, for each of the plurality of preset levels, identify at least one grammatical standard in the level mapping document that has a mapping relationship with the preset level; extract the highest grammatical standard and the lowest grammatical standard from the at least one grammatical standard; and construct the grammatical standard interval of the preset level using the highest grammatical standard and the lowest grammatical standard as interval endpoints.
[0045] Optionally, the storage module is further configured to, upon receiving a function configuration request, obtain the source code to be run carried in the function configuration request; for each of the plurality of preset levels, obtain the syntax standard range marked by the preset level, extract the lowest syntax standard from the two endpoints of the syntax standard range; call a language compilation tool to compile the source code to be run according to the lowest syntax standard to obtain a level code package, wherein the syntax of the code included in the level code package is the lowest syntax standard; and associate the level code package with the preset level for storage.
[0046] Optionally, the storage module is further configured to invoke the language compilation tool, determine the target attribute field in the language compilation tool; assign a value to the target attribute field using the lowest level syntax standard, and perform a compilation operation on the source code to be run based on the assigned value; and obtain the code package output by the language compilation tool as the level code package.
[0047] Optionally, the matching module is configured to query the minimum syntax standard supported by the target browser and use the minimum syntax standard as the target syntax standard; obtain multiple preset levels and the syntax standard interval marked in each of the multiple preset levels to obtain multiple syntax standard intervals; determine the target syntax standard interval to which the target syntax standard belongs in the multiple syntax standard intervals, and query the target preset level marked in the target syntax standard interval, and use the target preset level as the browser level of the target browser.
[0048] Optionally, the acquisition module is configured to continuously detect the current startup stage during the startup process of the target browser; when it detects that the current startup stage indicates the loading of browser resources, it queries a level code package that is associated with the browser level; and controls the target browser to load the level code package in the current startup stage.
[0049] According to a third aspect of this application, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method described in any of the first aspects above.
[0050] According to a fourth aspect of this application, a readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in any one of the first aspects above.
[0051] By means of the above technical solution, this application provides a browser running method, apparatus, computer device and readable storage medium. When a request to run a browser is detected, this application matches the browser level of the target browser to be run, obtains a browser level code package that includes code compiled using the minimum syntax standard supported by the target browser, and controls the target browser to execute the browser level code package so that the target browser can run successfully. The code involved in the browser level code package is all code that the browser can directly interpret, so that the browser can use its own native support for new features without having to use Babel as an intermediate layer to execute new features, resulting in higher execution performance.
[0052] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0053] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0054] Figure 1 A schematic flowchart of a browser operation method provided in an embodiment of this application is shown;
[0055] Figure 2 This paper illustrates a schematic flowchart of another browser operation method provided in an embodiment of this application;
[0056] Figure 3 A schematic diagram of the structure of a browser operating device provided in an embodiment of this application is shown;
[0057] Figure 4 A schematic diagram of the device structure of a computer device provided in an embodiment of this application is shown. Detailed Implementation
[0058] Exemplary embodiments of the present application will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this application will be thorough and complete, and will fully convey the scope of the present application to those skilled in the art.
[0059] This application provides a method for running a browser, such as... Figure 1As shown, the method includes:
[0060] 101. When a request to run a browser is detected, the requested browser is taken as the target browser, and the browser class of the target browser is matched.
[0061] In recent years, web front-end development has made rapid progress, and the JavaScript language standard is constantly being updated, with more and more new features gaining native browser support, such as classes, promises, and esm. However, due to the varying versions of users' browsers, practical applications need to accommodate older browsers. Therefore, the Babel tool emerged to effectively solve this problem. Babel is a tool commonly used to utilize the latest JavaScript language features, primarily converting code written in ECMAScript 2015+ syntax into backward-compatible JavaScript syntax, enabling it to run in current and older browsers or other environments. Therefore, using Babel's transpilation and compilation capabilities, developers can use ECMAScript 6 and above features and convert them into equivalent JavaScript for older versions, allowing browsers to interpret and run them.
[0062] To ensure compatibility with older browsers, the current mainstream approach is to use ECMAScript 6 or later language features in the source code, convert it to ECMAScript 5 syntax using Babel, and then add the Babel-polyfill module to provide APIs not supported by the browser, thus achieving compatibility with most browsers. However, the applicant recognizes that the above approach has a significant drawback: users with newer browsers still need to load some redundant code, and it does not utilize the browser's native support for new features. Therefore, the user experience can still be improved in this regard. Thus, this application proposes a browser execution method. When a request to run a browser is detected, the browser level of the target browser is matched, and a browser level-related code package, which includes code compiled using the minimum syntax standards supported by the target browser, is obtained. The target browser is then controlled to execute the browser level code package to ensure successful execution. The code in the browser-executed browser level code package is all code that the browser can directly interpret, allowing the browser to utilize its native support for new features without needing Babel as an intermediate layer, resulting in higher execution performance.
[0063] Therefore, in this embodiment, when a request to run a browser is detected, the requested browser is taken as the target browser, and its browser level is matched so that the corresponding level code package can be loaded for the browser accordingly. The browser level indicates the browser's support for language standards. The browser level can be determined based on the minimum supported syntax standards or the browser's version information. The level associated with the minimum syntax standards or version information is used as the browser level. This application does not limit the specific method for determining the browser level. The technical solution proposed in this application can be applied to servers providing online services to the target browser. The server can be an independent server or a server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. This allows the browser to directly load code packages, enabling it to run new features and provide users with services such as physical examinations, online medical consultations, and medical record viewing. Through the browser, users can browse medical data, electronic medical records, health check packages, and more. Specifically, medical data can include personal health records, prescription information, examination reports, and other data; electronic medical records are electronic healthcare records, which can include a series of electronic personal health records with archival value, such as medical records, electrocardiograms, and medical images; and health check packages can be the health check items or combinations of health check items that the browser can currently offer for purchase.
[0064] 102. Obtain the browser level-related code package.
[0065] In this embodiment, after matching the browser level of the target browser, the server obtains the level code package associated with the browser level. The code included in the level code package is compiled using the minimum syntax standard supported by the target browser. For example, assuming the minimum syntax standard supported by the target browser is ECMAScript 6, the code in the level code package is compiled using ECMAScript 6, so that the target browser can directly interpret the level code package and directly utilize its native support for new features.
[0066] 103. Control the target browser's execution level code package to ensure the target browser runs successfully.
[0067] In this embodiment, after obtaining the browser level-related code package, the server controls the target browser to execute the level code package so that the target browser can run successfully. That is, the code included in the level code package at this time is the syntax supported by the current target browser. For example, if the minimum syntax standard supported by a low-level browser is ECMAScript 3, then the code in the level code package executed by that browser is all ECMAScript 3 version of JavaScript code, which the browser runs directly.
[0068] The method provided in this application, when a request to run a browser is detected, matches the browser level of the target browser to be run, obtains a level code package associated with the browser level, which includes code compiled using the lowest syntax standard supported by the target browser, and controls the target browser to execute the level code package so that the target browser can run successfully. The code involved in the level code package executed by the browser is all code that the browser can directly interpret, so that the browser can use its own native support for new features without having to use the Babel tool as an intermediate layer to execute new features, resulting in higher execution performance.
[0069] Furthermore, as a refinement and extension of the specific implementation methods of the above embodiments, in order to fully illustrate the specific implementation process of this embodiment, this application provides another method for running a browser, such as... Figure 2 As shown, the method includes:
[0070] 201. In response to a level setting request, determine multiple preset levels and construct a grammar standard range for each of the multiple preset levels.
[0071] To provide browsers with directly interpretable code packages at runtime, this embodiment sets preset levels based on the degree of syntax standard support, so that the browser can subsequently determine which code package to load according to the level. The preset levels can be set by the developers themselves, and the specific setting process is as follows:
[0072] The server can set up a level setting entry point on the developer-facing frontend. When this entry point is triggered, the server confirms receipt of a level setting request from a developer and displays the level setting page. In practical applications, since developers may want to set many levels, manually entering the details of each level would involve a significant amount of manpower. Therefore, the server can set up a level file upload entry point on the level setting page. Developers can trigger this entry point to upload a pre-edited level mapping document to the server, allowing the server to automatically generate multiple preset levels based on the content of the mapping document.
[0073] Therefore, in response to a level setting request, the server retrieves the level mapping document carried in the level setting request and identifies the multiple preset levels included in the level mapping document.
[0074] Subsequently, based on the level mapping document, a syntax standard range is constructed for each of the multiple preset levels. Specifically, for each preset level, the server identifies at least one syntax standard that has a mapping relationship with the preset level in the level mapping document. From this at least one syntax standard, the highest and lowest syntax standards are extracted. Using the highest and lowest syntax standards as the endpoints of the range, the syntax standard range for the preset level is constructed. For example, assuming the level mapping document includes a preset level of "Advanced", and the syntax standards mapped to "Advanced" are ECMAScript 7, ECMAScript 8, and ECMAScript 9, the highest syntax standard can be determined to be ECMAScript 9, and the lowest syntax standard to be ECMAScript 7. Therefore, the syntax standard range constructed for the preset level "Advanced" is [ECMAScript 7~ECMAScript 9].
[0075] Finally, each preset level is labeled using the grammar standard range corresponding to each preset level, and the labeled preset levels are stored.
[0076] 202. When a function configuration request is received, obtain the source code to be run carried in the function configuration request, and configure the corresponding level code package for each preset level.
[0077] To ensure that each preset level corresponds to a code package compiled using the lowest syntax standard within that level, and that each browser assigned to that preset level can interpret the code package using its own characteristics, in this embodiment, after receiving the source code to be executed for configuring new features, the server uses a language compilation tool such as Babel to transform the source code, constructing code corresponding to the lowest language standard supported by each preset level as a level code package. This allows browsers of that preset level to interpret the level code package themselves. Specifically, the server can provide a feature configuration entry point on the developer-facing frontend. Developers can trigger this entry point to provide the server with the source code for new browser features, allowing the server to convert the source code into code that each browser level can interpret. The server's source code conversion process is as follows:
[0078] When a feature configuration request is received, the server retrieves the source code to be run, which is the source code provided by the developers to add new features to the browser. Then, for each of the multiple preset levels, the server obtains the syntax standard range marked for the preset level and extracts the lowest syntax standard from the two endpoints of the syntax standard range. Next, the server calls the language compilation tool to compile the source code to be run according to the lowest syntax standard, resulting in a level-one code package. The syntax of the code included in the level-one code package is also the lowest syntax standard. Finally, the server associates and stores the level-one code package with the preset level. For example, assuming the lowest syntax standard in the syntax standard range corresponding to the preset level "Advanced" is ECMAScript 7, then the Babel tool needs to compile the source code to be run according to ECMAScript 7. The compiled level-one code package contains code with ECMAScript 7 syntax, and no higher-level syntax exists.
[0079] In practical applications, language compilation tools such as Babel have a `Target` attribute field. By setting the syntax standard on this attribute field, the language compilation tool can be controlled to compile the code according to the specified syntax. Therefore, in an optional implementation, when calling the language compilation tool to compile the source code to be run, the language compilation tool can be called first. Within the language compilation tool, the target `Target` attribute field is determined, and a value is assigned to the `Target` attribute field using the lowest-level syntax standard. Based on this assignment, the language compilation tool then performs the compilation operation on the source code to be run, obtaining the code package output by the language compilation tool as the level code package. Specifically, the level code package can be a `Bundle` output by the language compilation tool, so that the browser can directly run it after obtaining the `Bundle`.
[0080] 203. When a request to run a browser is detected, the requested browser is selected as the target browser. The minimum syntax standard supported by the target browser is queried, and the minimum syntax standard is selected as the target syntax standard.
[0081] After setting multiple preset levels through steps 201 to 2020 above, and defining corresponding syntax standard ranges and level code packages for each preset level, the server can begin to strategically schedule browser loading of new features. Specifically, when a request to run a browser is detected, the server will use the requested browser as the target browser, query the minimum syntax standard supported by the target browser, and use the minimum syntax standard as the target syntax standard.
[0082] 204. Obtain multiple preset levels and the syntax standard range marked for each preset level in the multiple preset levels to obtain multiple syntax standard ranges. Determine the target syntax standard range to which the target syntax standard belongs in the multiple syntax standard ranges, and query the target preset level marked for the target syntax standard range. Use the target preset level as the browser level of the target browser.
[0083] In this embodiment, after determining the minimum syntax standard supported by the target browser and using this minimum syntax standard as the target syntax standard, the server obtains multiple preset levels and the syntax standard range marked for each preset level, resulting in multiple syntax standard ranges. The server then determines the target syntax standard range to which the target syntax standard belongs from these multiple syntax standard ranges. For example, assuming the syntax standard ranges marked for the multiple preset levels are [ECMAScript 7~ECMAScript 9], [ECMAScript 5~ECMAScript 6], and [ECMAScript 3~ECMAScript 5], and the target syntax standard is ECMAScript 5, then the target syntax standard range can be determined to be [ECMAScript 3~ECMAScript 5].
[0084] Subsequently, the server queries the target preset level marked in the target syntax standard range and uses this preset level as the browser level of the target browser. Continuing with the example of the target syntax standard range determined above as [ECMAScript3~ECMAScript5], if the server queries and determines that the syntax standard range marked with the preset level [low] is [ECMAScript3~ECMAScript5], then [low] can be determined as the browser level of the target browser.
[0085] 205. Obtain the browser rating code package.
[0086] In this embodiment of the application, after determining the browser level, the server obtains the level code package associated with the browser level. The code included in the level code package is compiled using the lowest syntax standard supported by the target browser, and there is no higher-level syntax.
[0087] Specifically, when obtaining the level code package, the server can continuously monitor the current startup stage during the target browser's startup process. When it detects that the current startup stage indicates that browser resources should be loaded, it queries the level code package that is related to the browser level and controls the target browser to load the level code package in the current startup stage, so that the browser can obtain and prepare the level code package and then directly execute the level code package.
[0088] 206. Control the target browser's execution level code package to ensure the target browser runs successfully.
[0089] In this embodiment, after obtaining the level code package, the server controls the target browser to execute the level code package so that the target browser can run successfully. At this time, the level code package obtained by the target browser must be the syntax supported by the current browser. For example, the code in the level code package obtained by a "low-level" browser is all ECMAScript3 version of Javascript code, so it can be run directly.
[0090] In this way, by adopting the technical solution disclosed in this application, users of newer browser versions do not need to load extra code and can directly use the new features provided by the browser. With fewer intermediate layers, the execution performance is higher. Moreover, over time, without changing the code, more and more users will have a better user experience, and the new features of the browser can be released in a gray-scale manner.
[0091] The method provided in this application embodiment involves code in the level code package executed by the browser that the browser can directly interpret, enabling the browser to utilize its native support for new features without needing to use Babel as an intermediate layer to execute new features, resulting in higher execution performance.
[0092] Furthermore, as Figure 1 To specifically implement the method, this application provides a browser operating device, such as... Figure 3 As shown, the device includes: a matching module 301, an acquisition module 302, and an operation module 303.
[0093] The matching module 301 is used to, when a request to run a browser is detected, take the requested browser as the target browser and match the browser level of the target browser;
[0094] The acquisition module 302 is used to acquire the browser level associated level code package, wherein the code included in the level code package is compiled using the lowest syntax standard supported by the target browser;
[0095] The runtime module 303 is used to control the target browser to execute the level code package so that the target browser can run successfully.
[0096] In specific application scenarios, the device also includes:
[0097] The acquisition module 302 is also used to acquire the level mapping relationship document carried by the level setting request in response to the level setting request;
[0098] A construction module is used to identify multiple preset levels included in the level mapping relationship document, and to construct a grammatical standard range for each of the multiple preset levels based on the level mapping relationship document;
[0099] The storage module is used to annotate each preset level using the syntax standard range corresponding to each preset level, and to store the annotated preset levels.
[0100] In specific application scenarios, this construction module is used to identify at least one grammatical standard that has a mapping relationship with the preset level in the level mapping relationship document for each of the multiple preset levels; extract the highest grammatical standard and the lowest grammatical standard from the at least one grammatical standard; and construct the grammatical standard interval of the preset level using the highest grammatical standard and the lowest level grammatical standard as interval endpoints.
[0101] In specific application scenarios, this storage module is also used to, when a function configuration request is received, obtain the source code to be run carried by the function configuration request; for each of the multiple preset levels, obtain the syntax standard range marked by the preset level, extract the lowest syntax standard from the two endpoints of the syntax standard range; call the language compilation tool to compile the source code to be run according to the lowest syntax standard to obtain a level code package, wherein the syntax of the code included in the level code package is the lowest syntax standard; and associate the level code package with the preset level for storage.
[0102] In specific application scenarios, this storage module is also used to call the language compilation tool, determine the target attribute field in the language compilation tool; assign a value to the target attribute field using the lowest level syntax standard, and perform a compilation operation on the source code to be run based on the assigned value; and obtain the code package output by the language compilation tool as the level code package.
[0103] In a specific application scenario, the matching module 301 is used to query the minimum syntax standard supported by the target browser and use the minimum syntax standard as the target syntax standard; obtain multiple preset levels and the syntax standard interval marked in each preset level to obtain multiple syntax standard intervals; determine the target syntax standard interval to which the target syntax standard belongs in the multiple syntax standard intervals, and query the target preset level marked in the target syntax standard interval, and use the target preset level as the browser level of the target browser.
[0104] In a specific application scenario, the acquisition module 302 is used to continuously detect the current startup stage during the startup process of the target browser; when it detects that the current startup stage indicates that browser resources are to be loaded, it queries the level code package that is related to the browser level; and controls the target browser to load the level code package in the current startup stage.
[0105] The apparatus provided in this application, when detecting a request to run a browser, matches the browser level of the target browser to be run, obtains a browser level code package that includes code compiled using the lowest syntax standard supported by the target browser, and controls the target browser to execute the browser level code package so that the target browser can run successfully. The code involved in the browser level code package is all code that the browser can directly interpret, so that the browser can use its own native support for new features without having to use the Babel tool as an intermediate layer to execute new features, resulting in higher execution performance.
[0106] It should be noted that other corresponding descriptions of the functional units involved in the browser operating device provided in this application embodiment can be found by referring to... Figure 1 and Figure 2 The corresponding descriptions in [the document] will not be repeated here.
[0107] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0108] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0109] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
[0110] In an exemplary embodiment, see Figure 4The invention also provides a computer device including a bus, a processor, a memory, and a communication interface. It may also include an input / output interface and a display device, wherein the various functional units can communicate with each other via the bus. The memory stores a computer program, and the processor executes the program stored in the memory to perform the browser operation method described in the above embodiments.
[0111] A computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the steps of the browser operation method.
[0112] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented in hardware or by using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) and includes several instructions to cause a computer device (such as a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0113] Those skilled in the art will understand that the accompanying drawings are merely schematic diagrams of a preferred embodiment, and the modules or processes shown in the drawings are not necessarily essential for implementing this application.
[0114] Those skilled in the art will understand that the modules in the apparatus of the implementation scenario can be distributed within the apparatus of the implementation scenario as described, or they can be located in one or more apparatuses different from this implementation scenario with corresponding changes. The modules of the above-mentioned implementation scenario can be combined into one module, or they can be further divided into multiple sub-modules.
[0115] The serial numbers in this application are for descriptive purposes only and do not represent the superiority or inferiority of the implementation scenario.
[0116] The above disclosures are only a few specific implementation scenarios of this application. However, this application is not limited to these. Any variations that can be conceived by those skilled in the art should fall within the protection scope of this application.
Claims
1. A method for operating a browser, characterized in that, include: When a request to run a browser is detected, the requested browser is taken as the target browser, and the browser level of the target browser is matched. The browser level is a target preset level marked by the target syntax standard interval to which the target syntax standard belongs, and the target syntax standard is the lowest syntax standard supported by the target browser. Matching the browser level of the target browser includes: querying the lowest syntax standard supported by the target browser, and taking the lowest syntax standard as the target syntax standard; obtaining multiple preset levels and the syntax standard interval marked by each preset level to obtain multiple syntax standard intervals; determining the target syntax standard interval to which the target syntax standard belongs among the multiple syntax standard intervals, and querying the target preset level marked by the target syntax standard interval, and taking the target preset level as the browser level of the target browser. Obtain the browser level associated level code package, wherein the code included in the level code package is compiled using the minimum syntax standard supported by the target browser; Control the target browser to execute the level code package so that the target browser can run successfully.
2. The method according to claim 1, characterized in that, Before determining the target browser and matching its browser class when a request to run a browser is detected, the method further includes: In response to a level setting request, obtain the level mapping relationship document carried in the level setting request; Identify multiple preset levels included in the level mapping document, and construct a grammatical standard range for each of the multiple preset levels based on the level mapping document; Each preset level is labeled using the grammar standard range corresponding to each preset level, and the labeled preset levels are stored.
3. The method according to claim 2, characterized in that, The step of constructing a grammatical standard range for each of the plurality of preset levels based on the level mapping relationship document includes: For each of the plurality of preset levels, at least one grammatical standard that has a mapping relationship with the preset level is identified in the level mapping relationship document; Extract the highest and lowest grammatical standards from the at least one grammatical standard; Using the highest and lowest grammatical standards as the endpoints, construct the preset level of grammatical standard intervals.
4. The method according to claim 2, characterized in that, After labeling each preset level using the syntax standard range corresponding to each preset level, and storing the labeled preset levels, the method further includes: When a function configuration request is received, the source code to be run carried in the function configuration request is obtained; For each of the plurality of preset levels, obtain the grammatical standard range marked by the preset level, and extract the lowest grammatical standard from the two endpoints of the grammatical standard range. The language compilation tool is invoked to compile the source code to be run according to the minimum syntax standard to obtain a first-level code package, wherein the syntax of the code included in the first-level code package is the minimum syntax standard; The level code package is associated with and stored with the preset level.
5. The method according to claim 4, characterized in that, The calling language compilation tool compiles the source code to be run according to the lowest level syntax standard to obtain a first-level code package, including: Invoke the language compilation tool and determine the target attribute field within the language compilation tool; The minimum syntax standard is used to assign values to the Target attribute field, and the language compilation tool is used to compile the source code to be run based on the assigned values. The code package output by the language compiler is obtained as the level code package.
6. The method according to claim 1, characterized in that, The step of obtaining the browser level-associated level code package includes: The current startup stage is continuously monitored during the startup process of the target browser; When the current startup phase indicates that browser resources are to be loaded, query the level code package that is related to the browser level; Control the target browser to load the level code package at the current startup stage.
7. A browser operating device, characterized in that, include: A matching module is used to, when a request to run a browser is detected, take the requested browser as the target browser and match the browser level of the target browser; wherein, the browser level is the target preset level marked by the target syntax standard interval to which the target syntax standard belongs, and the target syntax standard is the lowest syntax standard supported by the target browser; wherein, the matching module is used to query the lowest syntax standard supported by the target browser and take the lowest syntax standard as the target syntax standard; obtain multiple preset levels and the syntax standard interval marked by each preset level to obtain multiple syntax standard intervals; determine the target syntax standard interval to which the target syntax standard belongs in the multiple syntax standard intervals, and query the target preset level marked by the target syntax standard interval, and take the target preset level as the browser level of the target browser; The acquisition module is used to acquire the browser level associated level code package, wherein the code included in the level code package is compiled using the minimum syntax standard supported by the target browser; The runtime module is used to control the target browser to execute the level code package so that the target browser can run successfully.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Request response method and device
CN115033818A