CN111240767A - Component and page loading method and device, electronic equipment and storage medium - Google Patents

Component and page loading method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111240767A
CN111240767A CN202010079969.8A CN202010079969A CN111240767A CN 111240767 A CN111240767 A CN 111240767A CN 202010079969 A CN202010079969 A CN 202010079969A CN 111240767 A CN111240767 A CN 111240767A
Authority
CN
China
Prior art keywords
component
latest version
version number
local
version
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010079969.8A
Other languages
Chinese (zh)
Inventor
蒋圣
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010079969.8A priority Critical patent/CN111240767A/en
Publication of CN111240767A publication Critical patent/CN111240767A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • G06F9/44526Plug-ins; Add-ons
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Abstract

The embodiment of the disclosure discloses a component and page loading method and device, electronic equipment and a storage medium. The method comprises the following steps: executed by a browser for loading a page on which a target component is located, the method comprising: acquiring local storage resources and a corresponding local version number of the target component, and acquiring the latest version number of the target component from a server; if the local version number is the same as the latest version number, loading the local storage resource; if the local version number is different from the latest version number, acquiring difference information between the local version and the latest version of the target component from the server according to the local version number and the latest version number, acquiring latest version resources of the target component according to the difference information and the local storage resources, and loading the latest version resources. The technical scheme of the embodiment of the disclosure can reduce the data request to the server and save the data flow.

Description

Component and page loading method and device, electronic equipment and storage medium
Technical Field
The embodiment of the disclosure relates to the field of internet communication, in particular to a component and page loading method and device, electronic equipment and a storage medium.
Background
In daily life, people can obtain information on a network through mobile phones, tablet computers and other intelligent mobile devices everywhere.
Generally, a web page usually includes many components, and if one or more of the components are updated, the data resources cached locally by the browser cannot be used, and the data resources need to be retrieved from the server. However, when a user having an intelligent mobile device or using a fixed device browses network resources in an environment with poor network signals, if the data size of a page to be loaded is large, especially in the case of poor network signals, the opening speed of the page to be loaded is slow, which wastes time and data traffic.
Disclosure of Invention
In view of this, embodiments of the present disclosure provide a component and page loading method and apparatus, an electronic device, and a storage medium, so as to reduce data requests to a server and save data traffic.
Additional features and advantages of the disclosed embodiments will be set forth in the detailed description which follows, or in part will be obvious from the description, or may be learned by practice of the disclosed embodiments.
In a first aspect, an embodiment of the present disclosure provides a component loading method, which is executed by a browser for loading a page where a target component is located, where the method includes:
acquiring local storage resources and a corresponding local version number of the target component, and acquiring the latest version number of the target component from a server;
if the local version number is the same as the latest version number, loading the local storage resource;
if the local version number is different from the latest version number, acquiring difference information between the local version and the latest version of the target component from the server according to the local version number and the latest version number, acquiring latest version resources of the target component according to the difference information and the local storage resources, and loading the latest version resources.
In a second aspect, an embodiment of the present disclosure provides a page loading method, which is executed by a browser, and includes:
the method comprises the steps of obtaining local storage resources and corresponding version information of at least one component contained in a page, and obtaining latest version information of the at least one component from a server, wherein the version information at least comprises a component identifier and a version number;
performing the following operations on the at least one component respectively:
if the version number of the local storage resource of the component is the same as the latest version number, loading the local storage resource of the component;
if the version number of the local storage resource of the component is different from the latest version number, acquiring the difference information between the version of the local storage resource of the component and the latest version from the server according to the version number of the local storage resource and the latest version number, acquiring the latest version resource of the component according to the difference information and the local storage resource of the component, and loading the latest version resource of the component.
In a third aspect, an embodiment of the present disclosure further provides a component loading apparatus, including:
a version number obtaining unit, configured to obtain a local storage resource and a corresponding local version number of the target component, and obtain a latest version number of the target component from a server;
a local loading unit, configured to load the local storage resource if the local version number is the same as the latest version number;
and the fusion loading unit is used for acquiring difference information between the local version and the latest version of the target component from the server according to the local version number and the latest version number if the local version number is different from the latest version number, acquiring latest version resources of the target component according to the difference information and the local storage resources, and loading the latest version resources.
In a fourth aspect, an embodiment of the present disclosure further provides a page loading apparatus, including:
the version information acquisition unit is used for acquiring local storage resources and corresponding version information of at least one component contained in a page, and acquiring latest version information of the at least one component from a server, wherein the version information at least comprises a component identifier and a version number;
the local loading unit is used for respectively loading the local storage resources of the components if the version number of the local storage resources of the components is the same as the latest version number for the at least one component;
and the fusion loading unit is used for respectively loading the latest version resource of the component by acquiring the difference information between the version and the latest version of the local storage resource of the component from the server according to the version number and the latest version number of the local storage resource if the version number and the latest version number of the local storage resource of the component are different from each other, acquiring the latest version resource of the component according to the difference information and the local storage resource of the component.
In a fifth aspect, an embodiment of the present disclosure further provides an electronic device, including:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a method as claimed in any one of the first aspects.
In a sixth aspect, the disclosed embodiments also provide a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the method according to any one of the first aspect.
According to the technical scheme of the embodiment of the disclosure, the local storage resource and the corresponding local version number of the target component are obtained through the browser, the latest version number is obtained from the server, if the two version numbers are the same, the local storage resource is loaded, if the two version numbers are different, the difference information between the local version and the latest version of the target component is obtained from the server, the latest version resource of the target component is obtained according to the difference information and the local storage resource, and the latest version resource is loaded, so that the data request of the server can be reduced, and the data flow can be saved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings needed to be used in the description of the embodiments of the present disclosure will be briefly described below, and it is obvious that the drawings in the following description are only a part of the embodiments of the present disclosure, and for those skilled in the art, other drawings can be obtained according to the contents of the embodiments of the present disclosure and the drawings without creative efforts.
Fig. 1 is a schematic flow chart of a component loading method according to an embodiment of the present disclosure;
FIG. 2 is a schematic flow chart diagram illustrating another component loading method according to an embodiment of the present disclosure;
fig. 3 is a schematic flowchart of a page loading method according to an embodiment of the present disclosure;
fig. 4 is a schematic flowchart of another page loading method provided in the embodiment of the present disclosure;
FIG. 5 is a schematic diagram of a local index tree in another exemplary method for page loading according to an embodiment of the present disclosure;
FIG. 6 is a diagram of a newest index tree in another example method for page loading according to an embodiment of the present disclosure;
FIG. 7 is a schematic diagram of another page loading method provided by the embodiment of the present disclosure;
FIG. 8 is a schematic structural diagram of a component loading apparatus according to an embodiment of the present disclosure;
FIG. 9 is a schematic structural diagram of another component loading apparatus provided in the embodiments of the present disclosure;
fig. 10 is a schematic structural diagram of another page loading apparatus provided in the embodiment of the present disclosure;
FIG. 11 shows a schematic structural diagram of an electronic device suitable for use in implementing embodiments of the present disclosure.
Detailed Description
In order to make the technical problems solved, technical solutions adopted and technical effects achieved by the embodiments of the present disclosure clearer, the technical solutions of the embodiments of the present disclosure will be described in further detail below with reference to the accompanying drawings, and it is obvious that the described embodiments are only some embodiments, but not all embodiments, of the embodiments of the present disclosure. All other embodiments, which can be obtained by a person skilled in the art without making creative efforts based on the embodiments of the present disclosure, belong to the protection scope of the embodiments of the present disclosure.
It should be noted that the terms "system" and "network" are often used interchangeably in the embodiments of the present disclosure. Reference to "and/or" in embodiments of the present disclosure is meant to include any and all combinations of one or more of the associated listed items. The terms "first", "second", and the like in the description and claims of the present disclosure and in the drawings are used for distinguishing between different objects and not for limiting a particular order.
It should also be noted that, in the embodiments of the present disclosure, each of the following embodiments may be executed alone, or may be executed in combination with each other, and the embodiments of the present disclosure are not limited specifically.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
The technical solutions of the embodiments of the present disclosure are further described by the following detailed description in conjunction with the accompanying drawings.
Fig. 1 shows a schematic flow diagram of a component loading method provided in an embodiment of the present disclosure, where the embodiment is applicable to a situation where a web page is loaded when a component is updated, and the method is used for being executed by a browser that loads a page where a target component is located, as shown in fig. 1, the component loading method according to the embodiment includes:
in step S110, the local storage resource and the corresponding local version number of the target component are obtained, and the latest version number of the target component is obtained from the server.
The local storage resource may be a resource that is cached locally after the browser has loaded the target component last time, for example, the browser stores the resource that was loaded the target component last time in a local localstorage, and at this time, the local storage resource that acquires the target component may be acquired from the local localstorage.
In step S120, it is determined whether the local version number is the same as the latest version number, if so, step S130 is executed, and if not, step S140 is executed.
In step S130, the local storage resource is loaded.
In step S140, difference information between the local version and the latest version of the target component is obtained from the server according to the local version number and the latest version number, the latest version resource of the target component is obtained according to the difference information and the local storage resource, and the latest version resource is loaded.
For example, the difference information between the local version and the latest version of the target component includes patch resources for upgrading the target component from the local version to the latest version.
In addition, after step S140, the local version resource and the version number may be updated to the latest version resource and the latest version number, that is, the local storage resource of the target component is updated to the latest version resource, and the local version number is updated to the latest version number.
The method of the embodiment can be realized by executing the javascript code in the page through the browser.
According to the technical scheme of the embodiment, the local storage resource and the corresponding local version number of the target component are obtained through the browser, the latest version number is obtained from the server, if the two version numbers are the same, the local storage resource is loaded, if the two version numbers are different, the difference information between the local version and the latest version of the target component is obtained from the server, the latest version resource of the target component is obtained according to the difference information and the local storage resource, the latest version resource is loaded, the data request of the server can be reduced, and the data flow can be saved.
Fig. 2 is a schematic flow chart of another component loading method provided in the embodiment of the present disclosure, and the embodiment is based on the foregoing embodiment and is optimized. As shown in fig. 2, the component loading method according to this embodiment includes:
in step S210, the local storage resource and the corresponding local version number of the target component are obtained, and the latest version number of the target component is obtained from the server.
In step S220, the hash value of the latest version of the target component is obtained from the server.
It should be noted that the hash value is obtained by performing calculation according to code resources, for example, MD5 calculation is performed on the code of the corresponding version, and the hash value of the corresponding version corresponding to the first N bits of MD5 is obtained according to the result of the MD5 calculation.
In step S230, it is determined whether the local version number is the same as the latest version number, if so, step S240 is executed, and if not, step S250 is executed.
In step S240, the local storage resource is loaded.
For example, the browser caches the resource that accessed the target component last time in the local localstorage, this step may obtain the local storage resource of the target component from the local localstorage.
In step S250, according to the local version number and the latest version number, difference information between the local version and the latest version of the target component is obtained from the server, according to the difference information and the local storage resource, the latest version resource of the target component is obtained, a hash value of the latest version resource is calculated, and if the calculated hash value is the same as the hash value obtained from the server, the latest version resource is loaded.
Wherein the difference information between the local version and the latest version of the target component may include patch resources for upgrading the target component from the local version to the latest version.
Further, after step S250, the local storage resource of the target component may also be updated to the latest version resource, and the local version number may also be updated to the latest version number.
The embodiment further discloses that the hash value of the version is also obtained on the basis of obtaining the version number, so that the correctness of the latest version resource synthesized according to the local resource and the version difference information is verified, and the robustness of the code can be further improved.
Fig. 3 shows a schematic flow diagram of a page loading method provided by an embodiment of the present disclosure, where the embodiment is applicable to a situation where a web page is loaded when a component is updated, and the method is used for being executed by a browser that loads a target page, and as shown in fig. 3, the page loading method according to the embodiment includes:
in step S310, a local storage resource and corresponding version information of at least one component included in the page are obtained.
In step S320, the latest version information of the at least one component is acquired from the server.
Wherein the version information comprises at least a component identification and a version number.
In step S330, the two version numbers of each component are compared, and for components with unchanged version numbers, step S340 is performed, and for components with different version numbers, step S350 is performed.
The version number corresponding to the local resource of the at least one component is compared with the latest version number of the server side, and whether the two version numbers are the same or not is judged.
In step S340, for components whose version numbers do not change, the local storage resource is loaded.
In step S350, for components with different version numbers, according to the component identifier and the version number, difference information is obtained from the server and fused with the local resource to obtain the latest version resource.
Further, the version information may further include a code hash value, and after obtaining the latest version resource, the method further includes calculating a hash value of the latest version resource of the component.
Before loading the latest version of resource, performing hash check on the latest resource, including:
and if the calculated hash value is the same as the hash value of the version information acquired from the server, loading the latest version resource of the component.
Further, if the version number of the local storage resource of the component is different from the latest version number, updating the local resource and the version number after loading the latest version resource of the component includes: updating the local storage resource of the component to a latest version resource of the component, and updating the local version number of the component to a latest version number of the component.
Further, the version information may further include a direct dependent component, the version information of the at least one component forms an index tree, each component in the at least one component corresponds to a node of the index tree, and a connection relationship between nodes in the index tree corresponds to a dependency relationship between the at least one component.
The method can be realized by executing the javascript file in the page (namely the JS file linked in the page) through the browser.
According to the technical scheme of the embodiment, the local storage resource and the corresponding version information of at least one component contained in the page are obtained through the browser, the latest version information of the at least one component is obtained from the server, two version numbers of each component are compared, the local storage resource is loaded for the component with the unchanged version number, and for the components with different version numbers, the difference information is obtained from the server according to the component identification and the version number and is fused with the local resource to obtain the latest version resource, so that the data request of the server can be reduced, and the data flow can be saved.
Based on the previous embodiment, this embodiment discloses, by taking a page of a single-page application as an example, that version information further includes a condition of directly depending on components, where the version information of the components included in the page of the single-page application forms an index tree, each component in the at least one component corresponds to a node of the index tree, and a connection relationship between the nodes in the index tree corresponds to a dependency relationship between the at least one component. As shown in fig. 4, the component loading method according to this embodiment includes:
in step S410, a page of a single-page application is accessed.
In step S420, the JS file of the page is loaded.
The page includes components A, B and C. Components B and C have no directly dependent components, and component A depends on components B and C.
In step S430, the last index tree is read from LocalStorage.
For example, a schematic diagram of a local index tree of a target page is shown in fig. 5, in LocalStorage, a version number of a component a in a last index tree is version 1, a version number of a component B is version 1, and a version number of a component C is version 1.
In step S440, the latest index tree is read from the server.
For example, as shown in fig. 6, a schematic diagram of the latest index tree read by the server is shown, where the latest version number of the component a in the server is version 1, the latest version number of the component B is version 1, and the latest version number of the component C is version 2. .
In step S450, the two versions of the index tree are compared.
The comparison shows that the version number of the component C is different, and the version numbers of the components A and B are the same.
In step S460, for the unchanged component, the last cache is directly read.
In step S470, for the updated component, the difference information is obtained from the server according to the component identifier and the version number and merged.
For example, a schematic diagram of fusion based on difference information is shown in fig. 7.
For example, a "component C-1" represents a resource of version 1 of the component C, a "component C-2" represents a resource of version 2 of the component C, and a "component C-1-2" represents difference information of version 1 and version 2 of the component C, specifically, a patch resource for upgrading the component C from version 1 to version 2.
The step of performing fusion may be exemplified as:
component C-1+ component C-1-2 ═ component C-2
In step S480, all components are merged and the component is run.
The present embodiment discloses a version information further including a condition of directly depending on components, based on the previous embodiment, where the page of a single-page application is taken as an example, and the version information of the components included in the page of the single-page application forms a condition of an index tree, and the version information of each component included in the page is centrally managed in a tree form, so that when the page is loaded, two version trees are read first, and compared in batch, so as to further improve the loading efficiency of the page.
As an implementation of the method shown in fig. 1 and fig. 2, an embodiment of the present disclosure provides an embodiment of a component loading apparatus, and fig. 8 illustrates a schematic structural diagram of the component loading apparatus provided in this embodiment, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 1 and fig. 2, and the apparatus may be specifically applied to various electronic devices. As shown in fig. 8, the component loading apparatus according to this embodiment includes a version number obtaining unit 810, a local loading unit 820, and a fused loading unit 830.
The version number obtaining unit 810 is configured to obtain a local storage resource and a corresponding local version number of the target component, and obtain a latest version number of the target component from a server.
The local loading unit 820 is configured to load the local storage resource if the local version number is the same as the latest version number.
The merge loading unit 830 is configured to, if the local version number is different from the latest version number, obtain difference information between the local version and the latest version of the target component from the server according to the local version number and the latest version number, obtain latest version resources of the target component according to the difference information and the local storage resources, and load the latest version resources.
Further, the difference information between the local version and the latest version of the target component includes patch resources for upgrading the target component from the local version to the latest version.
Further, the version number obtaining unit is configured to obtain a local storage resource of the target component from a local localstorage.
Further, the device is realized by executing the javascript code in the page through the browser.
The component loading device provided by the embodiment can execute the component loading method provided by the embodiment of the method disclosed by the invention, and has corresponding functional modules and beneficial effects of the execution method.
Fig. 9 shows a schematic structural diagram of another component loading apparatus provided in the embodiment of the present disclosure, and as shown in fig. 9, the component loading apparatus according to the embodiment includes: a version number obtaining unit 910, a hash value obtaining unit 920, a local loading unit 930, a fused loading unit 940, and a local updating unit 950.
The version number obtaining unit 910 is configured to obtain a local storage resource and a corresponding local version number of the target component, and obtain a latest version number of the target component from a server.
The hash value obtaining unit 920 is configured to obtain the hash value of the latest version of the target component from the server.
The local loading unit 930 is configured to load the local storage resource if the local version number is the same as the latest version number.
The merge loading unit 940 is configured to, if the local version number is different from the latest version number, obtain difference information between the local version and the latest version of the target component from the server according to the local version number and the latest version number, obtain the latest version resource of the target component according to the difference information and the local storage resource, calculate a hash value of the latest version resource, and load the latest version resource if the calculated hash value is the same as the hash value obtained from the server.
The local updating unit 950 is configured to update the local storage resource of the target component to the latest version resource and update the local version number to the latest version number after loading the latest version resource if the local version number is different from the latest version number.
Further, the difference information between the local version and the latest version of the target component includes patch resources for upgrading the target component from the local version to the latest version.
Further, the version number obtaining unit 910 is configured to obtain a local storage resource of the target component from a local localstorage.
Further, the device is realized by executing the javascript code in the page through the browser.
The component loading device provided by the embodiment can execute the component loading method provided by the embodiment of the method disclosed by the invention, and has corresponding functional modules and beneficial effects of the execution method.
As an implementation of the methods shown in fig. 3 to fig. 7, the present application provides an embodiment of a page loading apparatus, and fig. 10 illustrates a schematic structural diagram of a page loading apparatus provided in this embodiment, where the embodiment of the apparatus corresponds to the method embodiments shown in fig. 3 to fig. 7, and the apparatus may be specifically applied to various electronic devices. As shown in fig. 10, the component loading apparatus according to this embodiment includes: a version information acquisition unit 1010, a local loading unit 1020, and a fused loading unit 1030.
The version information obtaining unit 1010 is configured to obtain a local storage resource and corresponding version information of at least one component included in a page, and obtain latest version information of the at least one component from a server, where the version information includes at least a component identifier and a version number.
The local loading unit 1020 is configured to, for each of the at least one component, load the local storage resource of the component if the version number of the local storage resource of the component is the same as the latest version number.
The fusion loading unit 1030 is configured to, for each of the at least one component, if a version number of a local storage resource of the component is different from a latest version number, obtain, from the server, difference information between a version and a latest version of the local storage resource of the component according to the version number of the local storage resource and the latest version number, obtain, according to the difference information and the local storage resource of the component, a latest version resource of the component, and load the latest version resource of the component.
Further, the version information further includes a code hash value;
the merge loading unit 1030 is further configured to calculate a hash value of the latest version resource of the component after acquiring the latest version resource of the component according to the difference information and the local storage resource of the component, and load the latest version resource of the component if the calculated hash value is the same as the hash value of the version information acquired from the server.
Further, the apparatus further includes a local updating unit (not shown in fig. 10) configured to update the local storage resource of the component to a latest version resource of the component and update the local version number of the component to a latest version number of the component after the latest version resource of the component is loaded if the version number of the local storage resource of the component is different from the latest version number.
Further, the version information also includes a direct dependent component; the version information of the at least one component forms an index tree, each component in the at least one component corresponds to a node of the index tree, and the connection relationship of the nodes in the index tree corresponds to the dependency relationship of the at least one component.
Further, the device is realized by executing the javascript file in the page through a browser.
Further, the page is a page of a single-page application.
The page loading device provided by the embodiment can execute the page loading method provided by the embodiment of the method disclosed by the invention, and has corresponding functional modules and beneficial effects of the execution method.
Referring now to FIG. 11, shown is a schematic diagram of an electronic device 1100 suitable for use in implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 11 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 11, the electronic device 1100 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 1101 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)1102 or a program loaded from a storage means 1108 into a Random Access Memory (RAM) 1103. In the RAM 1103, various programs and data necessary for the operation of the electronic device 1100 are also stored. The processing device 1101, the ROM 1102, and the RAM 1103 are connected to each other by a bus 1104. An input/output (I/O) interface 1105 is also connected to bus 1104.
Generally, the following devices may be connected to the I/O interface 1105: input devices 1106 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 1107 including, for example, Liquid Crystal Displays (LCDs), speakers, vibrators, and the like; storage devices 1108, including, for example, magnetic tape, hard disk, etc.; and a communication device 1109. The communication means 1109 may allow the electronic device 1100 to communicate wirelessly or wiredly with other devices to exchange data. While fig. 11 illustrates an electronic device 1100 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated by the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via the communication device 1109, or installed from the storage device 1108, or installed from the ROM 1102. The computer program, when executed by the processing device 1101, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium described above in the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the disclosed embodiments, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the disclosed embodiments, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to:
acquiring local storage resources and a corresponding local version number of the target component, and acquiring the latest version number of the target component from a server;
if the local version number is the same as the latest version number, loading the local storage resource;
if the local version number is different from the latest version number, acquiring difference information between the local version and the latest version of the target component from the server according to the local version number and the latest version number, acquiring latest version resources of the target component according to the difference information and the local storage resources, and loading the latest version resources.
Or:
the method comprises the steps of obtaining local storage resources and corresponding version information of at least one component contained in a page, and obtaining latest version information of the at least one component from a server, wherein the version information at least comprises a component identifier and a version number;
performing the following operations on the at least one component respectively:
if the version number of the local storage resource of the component is the same as the latest version number, loading the local storage resource of the component;
if the version number of the local storage resource of the component is different from the latest version number, acquiring the difference information between the version of the local storage resource of the component and the latest version from the server according to the version number of the local storage resource and the latest version number, acquiring the latest version resource of the component according to the difference information and the local storage resource of the component, and loading the latest version resource of the component.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a unit does not in some cases constitute a limitation of the unit itself, for example, the first retrieving unit may also be described as a "unit for retrieving at least two internet protocol addresses".
According to one or more embodiments of the present disclosure, in the component loading method, the difference information between the local version and the latest version of the target component includes a patch resource for upgrading the target component from the local version to the latest version.
According to one or more embodiments of the present disclosure, the component loading method further includes obtaining a hash value of a latest version of the target component from a server;
calculating a hash value of the latest version resource after acquiring the latest version resource of the target component according to the difference information and the local storage resource;
loading the latest version of the resource further includes loading the latest version of the resource if the computed hash value is the same as the hash value obtained from the server.
According to one or more embodiments of the present disclosure, in the component loading method, if the local version number is different from the latest version number, after loading the latest version resource, the method further includes:
updating a local storage resource of the target component to the latest version resource, and updating the local version number to the latest version number.
According to one or more embodiments of the present disclosure, in the component loading method, acquiring the local storage resource of the target component includes acquiring the local storage resource of the target component from a local localstorage.
According to one or more embodiments of the disclosure, the component loading method is implemented by the browser executing javascript codes in the page.
According to one or more embodiments of the present disclosure, in the page loading method, the version information further includes a code hash value;
calculating the hash value of the latest version resource of the component after acquiring the latest version resource of the component according to the difference information and the local storage resource of the component;
loading the latest version resource further includes loading the latest version resource of the component if the calculated hash value is the same as the hash value of the version information acquired from the server.
According to one or more embodiments of the present disclosure, in the page loading method, if the version number of the local storage resource of the component is different from the latest version number, after loading the latest version resource of the component, the method further includes:
updating the local storage resource of the component to a latest version resource of the component, and updating the local version number of the component to a latest version number of the component.
According to one or more embodiments of the present disclosure, in the page loading method:
the version information further includes a direct dependent component;
the version information of the at least one component forms an index tree, each component in the at least one component corresponds to a node of the index tree, and the connection relationship of the nodes in the index tree corresponds to the dependency relationship of the at least one component.
According to one or more embodiments of the disclosure, the page loading method is implemented by executing a javascript file in the page through a browser.
According to one or more embodiments of the present disclosure, in the page loading method, the page is a page of a single-page application.
According to one or more embodiments of the present disclosure, in the component loading apparatus, the difference information between the local version and the latest version of the target component includes a patch resource for upgrading the target component from the local version to the latest version.
According to one or more embodiments of the present disclosure, the component loading apparatus further includes a hash value obtaining unit, configured to obtain, from a server, a hash value of a latest version of the target component;
the fusion loading unit is further configured to calculate a hash value of the latest version resource of the target component after acquiring the latest version resource of the target component according to the difference information and the local storage resource, and load the latest version resource if the calculated hash value is the same as the hash value acquired from the server.
According to one or more embodiments of the present disclosure, the component loading apparatus further includes a local updating unit, configured to update the local storage resource of the target component to the latest version resource and update the local version number to the latest version number after the latest version resource is loaded if the local version number is different from the latest version number.
According to one or more embodiments of the present disclosure, in the component loading apparatus, the version number obtaining unit is configured to obtain a local storage resource of the target component from a local localstorage.
According to one or more embodiments of the present disclosure, the component loading apparatus is implemented by the browser executing javascript code in the page.
According to one or more embodiments of the present disclosure, in the page loading apparatus, the version information further includes a code hash value;
the fusion loading unit is further configured to calculate a hash value of the latest version resource of the component after acquiring the latest version resource of the component according to the difference information and the local storage resource of the component, and load the latest version resource of the component if the calculated hash value is the same as the hash value of the version information acquired from the server.
According to one or more embodiments of the present disclosure, the page loading apparatus further includes a local updating unit, configured to update the local storage resource of the component to a latest version resource of the component and update the local version number of the component to a latest version number of the component after loading the latest version resource of the component if the version number of the local storage resource of the component is different from the latest version number.
According to one or more embodiments of the present disclosure, in the page loading apparatus:
the version information further includes a direct dependent component;
the version information of the at least one component forms an index tree, each component in the at least one component corresponds to a node of the index tree, and the connection relationship of the nodes in the index tree corresponds to the dependency relationship of the at least one component.
According to one or more embodiments of the disclosure, the page loading device is implemented by executing a javascript file in the page through a browser.
According to one or more embodiments of the present disclosure, in the page loading device, the page is a page of a single-page application.
The foregoing description is only a preferred embodiment of the disclosed embodiments and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure in the embodiments of the present disclosure is not limited to the particular combination of the above-described features, but also encompasses other embodiments in which any combination of the above-described features or their equivalents is possible without departing from the scope of the present disclosure. For example, the above features and (but not limited to) the features with similar functions disclosed in the embodiments of the present disclosure are mutually replaced to form the technical solution.

Claims (16)

1. A component loading method is characterized by being executed by a browser for loading a page where a target component is located, and the method comprises the following steps:
acquiring local storage resources and a corresponding local version number of the target component, and acquiring the latest version number of the target component from a server;
if the local version number is the same as the latest version number, loading the local storage resource;
if the local version number is different from the latest version number, acquiring difference information between the local version and the latest version of the target component from the server according to the local version number and the latest version number, acquiring latest version resources of the target component according to the difference information and the local storage resources, and loading the latest version resources.
2. The method of claim 1, wherein the difference information between the local version and the latest version of the target component comprises: patch resources for upgrading the target component from the local version to the latest version.
3. The method of claim 1, further comprising: obtaining the hash value of the latest version of the target component from a server;
calculating a hash value of the latest version resource after acquiring the latest version resource of the target component according to the difference information and the local storage resource;
the loading the latest version resource further comprises: and if the calculated hash value is the same as the hash value acquired from the server, loading the latest version resource.
4. The method of claim 1, wherein if the local version number is different from the latest version number, further comprising, after loading the latest version resource:
updating a local storage resource of the target component to the latest version resource, and updating the local version number to the latest version number.
5. The method of claim 1, wherein obtaining the local storage resource of the target component comprises: and acquiring the local storage resource of the target component from the local LocalStroage.
6. The method of claim 1, wherein the method is implemented by the browser executing javascript code in the page.
7. A page loading method, performed by a browser, the method comprising:
the method comprises the steps of obtaining local storage resources and corresponding version information of at least one component contained in a page, and obtaining latest version information of the at least one component from a server, wherein the version information at least comprises a component identifier and a version number;
performing the following operations on the at least one component respectively:
if the version number of the local storage resource of the component is the same as the latest version number, loading the local storage resource of the component;
if the version number of the local storage resource of the component is different from the latest version number, acquiring the difference information between the version of the local storage resource of the component and the latest version from the server according to the version number of the local storage resource and the latest version number, acquiring the latest version resource of the component according to the difference information and the local storage resource of the component, and loading the latest version resource of the component.
8. The method of claim 7, wherein the version information further comprises a code hash value;
after acquiring the latest version resource of the component according to the difference information and the local storage resource of the component, the method further comprises the following steps: calculating a hash value of the latest version resource of the component;
the loading the latest version resource of the component further comprises: and if the calculated hash value is the same as the hash value of the version information acquired from the server, loading the latest version resource of the component.
9. The method of claim 7, wherein if the version number of the locally stored resource of a component is different from the latest version number, further comprising, after loading the latest version resource of the component:
updating the local storage resource of the component to a latest version resource of the component, and updating the local version number of the component to a latest version number of the component.
10. The method of claim 7, wherein:
the version information further includes a direct dependent component;
the version information of the at least one component forms an index tree, each component in the at least one component corresponds to a node of the index tree, and the connection relationship of the nodes in the index tree corresponds to the dependency relationship of the at least one component.
11. The method of claim 7, wherein the method is implemented by a browser executing a javascript file in the page.
12. The method of claim 7, wherein the page is a page of a single-page application.
13. A component loading apparatus, comprising:
a version number obtaining unit, configured to obtain a local storage resource and a corresponding local version number of the target component, and obtain a latest version number of the target component from a server;
a local loading unit, configured to load the local storage resource if the local version number is the same as the latest version number;
and the fusion loading unit is used for acquiring difference information between the local version and the latest version of the target component from the server according to the local version number and the latest version number if the local version number is different from the latest version number, acquiring latest version resources of the target component according to the difference information and the local storage resources, and loading the latest version resources.
14. A page loading apparatus, comprising:
the version information acquisition unit is used for acquiring local storage resources and corresponding version information of at least one component contained in a page, and acquiring latest version information of the at least one component from a server, wherein the version information at least comprises a component identifier and a version number;
the local loading unit is used for respectively loading the local storage resources of the components if the version number of the local storage resources of the components is the same as the latest version number for the at least one component;
and the fusion loading unit is used for respectively loading the latest version resource of the component by acquiring the difference information between the version and the latest version of the local storage resource of the component from the server according to the version number and the latest version number of the local storage resource if the version number and the latest version number of the local storage resource of the component are different from each other, acquiring the latest version resource of the component according to the difference information and the local storage resource of the component.
15. An electronic device, comprising:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-12.
16. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-12.
CN202010079969.8A 2020-02-04 2020-02-04 Component and page loading method and device, electronic equipment and storage medium Pending CN111240767A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010079969.8A CN111240767A (en) 2020-02-04 2020-02-04 Component and page loading method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010079969.8A CN111240767A (en) 2020-02-04 2020-02-04 Component and page loading method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111240767A true CN111240767A (en) 2020-06-05

Family

ID=70874943

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010079969.8A Pending CN111240767A (en) 2020-02-04 2020-02-04 Component and page loading method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111240767A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112214270A (en) * 2020-09-18 2021-01-12 北京鸿腾智能科技有限公司 Page redrawing method, device, equipment and storage medium
CN112286545A (en) * 2020-09-21 2021-01-29 长沙市到家悠享网络科技有限公司 Data updating method, device, equipment and storage medium
CN112783515A (en) * 2021-02-08 2021-05-11 腾讯科技(深圳)有限公司 Plug-in control method and device and storage medium
CN112882764A (en) * 2021-01-20 2021-06-01 网易(杭州)网络有限公司 Component loading method and device, computer equipment and storage medium
CN113542884A (en) * 2021-07-14 2021-10-22 视若飞信息科技(上海)有限公司 Method for synchronizing JS patch files between smart television browser and server
CN113553058A (en) * 2021-07-23 2021-10-26 深圳万顺叫车云信息技术有限公司 Front-end page access method and system and electronic equipment

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1735862A (en) * 2003-12-15 2006-02-15 微软公司 System and method for updating installation components in a networked environment
US20140032502A1 (en) * 2008-05-12 2014-01-30 Adobe Systems Incorporated History-based archive management
CN103699410A (en) * 2013-12-20 2014-04-02 北京奇虎科技有限公司 Method and device for updating application programs
CN105337776A (en) * 2015-11-19 2016-02-17 北京金山安全软件有限公司 Method and device for generating website fingerprint and electronic equipment
US20160291940A1 (en) * 2014-07-07 2016-10-06 Symphony Teleca Corporation Remote Embedded Device Update Platform Apparatuses, Methods and Systems
CN106648716A (en) * 2015-10-30 2017-05-10 北京数码视讯科技股份有限公司 Increment updating method, server and intelligent card
CN108111331A (en) * 2017-11-06 2018-06-01 北京趣拿软件科技有限公司 Acquisition methods, device, storage medium, processor and the system of updated data package
CN108241500A (en) * 2018-01-15 2018-07-03 腾讯科技(深圳)有限公司 A kind of restorative procedure of hardware component, device, system and storage medium
CN109144548A (en) * 2018-08-27 2019-01-04 杭州安恒信息技术股份有限公司 A kind of multicompartment software upgrade method, device and server realized based on git
CN109388423A (en) * 2017-08-03 2019-02-26 合网络技术(北京)有限公司 Method for upgrading software and device
CN109614165A (en) * 2018-12-04 2019-04-12 山东财经大学 A kind of parallel operation method of the multi version of com component and device
CN110012096A (en) * 2019-04-03 2019-07-12 中国工商银行股份有限公司 Mobile client service updates management method, apparatus and system
CN110377360A (en) * 2019-07-12 2019-10-25 深圳市酷开网络科技有限公司 Method, display terminal and the computer readable storage medium that webview is quickly loaded

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1735862A (en) * 2003-12-15 2006-02-15 微软公司 System and method for updating installation components in a networked environment
US20140032502A1 (en) * 2008-05-12 2014-01-30 Adobe Systems Incorporated History-based archive management
CN103699410A (en) * 2013-12-20 2014-04-02 北京奇虎科技有限公司 Method and device for updating application programs
US20160291940A1 (en) * 2014-07-07 2016-10-06 Symphony Teleca Corporation Remote Embedded Device Update Platform Apparatuses, Methods and Systems
CN106648716A (en) * 2015-10-30 2017-05-10 北京数码视讯科技股份有限公司 Increment updating method, server and intelligent card
CN105337776A (en) * 2015-11-19 2016-02-17 北京金山安全软件有限公司 Method and device for generating website fingerprint and electronic equipment
CN109388423A (en) * 2017-08-03 2019-02-26 合网络技术(北京)有限公司 Method for upgrading software and device
CN108111331A (en) * 2017-11-06 2018-06-01 北京趣拿软件科技有限公司 Acquisition methods, device, storage medium, processor and the system of updated data package
CN108241500A (en) * 2018-01-15 2018-07-03 腾讯科技(深圳)有限公司 A kind of restorative procedure of hardware component, device, system and storage medium
CN109144548A (en) * 2018-08-27 2019-01-04 杭州安恒信息技术股份有限公司 A kind of multicompartment software upgrade method, device and server realized based on git
CN109614165A (en) * 2018-12-04 2019-04-12 山东财经大学 A kind of parallel operation method of the multi version of com component and device
CN110012096A (en) * 2019-04-03 2019-07-12 中国工商银行股份有限公司 Mobile client service updates management method, apparatus and system
CN110377360A (en) * 2019-07-12 2019-10-25 深圳市酷开网络科技有限公司 Method, display terminal and the computer readable storage medium that webview is quickly loaded

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112214270A (en) * 2020-09-18 2021-01-12 北京鸿腾智能科技有限公司 Page redrawing method, device, equipment and storage medium
CN112286545A (en) * 2020-09-21 2021-01-29 长沙市到家悠享网络科技有限公司 Data updating method, device, equipment and storage medium
CN112882764A (en) * 2021-01-20 2021-06-01 网易(杭州)网络有限公司 Component loading method and device, computer equipment and storage medium
CN112882764B (en) * 2021-01-20 2022-07-22 网易(杭州)网络有限公司 Component loading method and device, computer equipment and storage medium
CN112783515A (en) * 2021-02-08 2021-05-11 腾讯科技(深圳)有限公司 Plug-in control method and device and storage medium
CN112783515B (en) * 2021-02-08 2023-08-25 腾讯科技(深圳)有限公司 Plug-in control method and device and storage medium
CN113542884A (en) * 2021-07-14 2021-10-22 视若飞信息科技(上海)有限公司 Method for synchronizing JS patch files between smart television browser and server
CN113553058A (en) * 2021-07-23 2021-10-26 深圳万顺叫车云信息技术有限公司 Front-end page access method and system and electronic equipment

Similar Documents

Publication Publication Date Title
CN111240767A (en) Component and page loading method and device, electronic equipment and storage medium
CN111581563B (en) Page response method and device, storage medium and electronic equipment
CN110865852B (en) Webpage component loading method and device, electronic equipment and storage medium
CN111274503B (en) Data processing method, device, electronic equipment and computer readable medium
CN112416425B (en) APP construction method and device, computer equipment and storage medium
CN111857720B (en) User interface state information generation method and device, electronic equipment and medium
CN111694629A (en) Information display method and device and electronic equipment
CN111273985A (en) Page rendering method and device, electronic equipment and computer readable storage medium
CN114625536A (en) Video memory allocation method, device, medium and electronic equipment
CN112836093B (en) Data query method, device, electronic equipment and storage medium
CN111596992B (en) Navigation bar display method and device and electronic equipment
CN111191225B (en) Method, device, medium and electronic equipment for switching isolated objects
CN111400068B (en) Interface control method and device, readable medium and electronic equipment
CN111241137B (en) Data processing method, device, electronic equipment and storage medium
CN110674082B (en) Method and device for removing online document, electronic equipment and computer readable medium
CN111177634A (en) Multi-language supporting file content loading method, device, equipment and medium
CN114327453B (en) Page display method, device, equipment and storage medium
CN114741686A (en) Method and device for detecting program white list and related equipment
CN111460020B (en) Method, device, electronic equipment and medium for resolving message
CN113971192A (en) Data processing method and device, readable medium and electronic equipment
CN112230986A (en) Project file generation method and device, electronic equipment and computer readable medium
CN111580890A (en) Method, apparatus, electronic device, and computer-readable medium for processing features
CN113391860A (en) Service request processing method and device, electronic equipment and computer storage medium
CN112445820A (en) Data conversion method and device
CN113448550B (en) Method and device for realizing collection management of classes, electronic equipment and computer 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