CN104965848B - A kind of front end resource loading method and device - Google Patents
A kind of front end resource loading method and device Download PDFInfo
- Publication number
- CN104965848B CN104965848B CN201510075489.3A CN201510075489A CN104965848B CN 104965848 B CN104965848 B CN 104965848B CN 201510075489 A CN201510075489 A CN 201510075489A CN 104965848 B CN104965848 B CN 104965848B
- Authority
- CN
- China
- Prior art keywords
- loaded
- end resource
- resource
- web document
- module
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Landscapes
- Information Transfer Between Computers (AREA)
Abstract
The present invention relates to a kind of front end resource loading method and device, wherein this method includes:Client is obtained and parses the web document of targeted sites, and the description information of front end resource to be loaded is included in the web document;According to the description information of the front end resource to be loaded, judge whether that the front end resource to be loaded is being locally stored;If so, then reading the front end resource to be loaded and being added into the web document, if it is not, then asking to download the front end resource to be loaded to server, the front end resource to be loaded of download is added into the web document;Displaying is added into the web document of the front end resource to be loaded.The above method and device can improve the speed of non-front end resource needed for loading when using the client first, reduce the shared flow of loading, and reduce when client renders webpage due to load the front end resource and caused by interruption rate.
Description
Technical field
The present invention relates to field of computer technology, more particularly to a kind of front end resource loading method and device.
Background technology
Single page Web is a kind of special Web applications using (SPA, single-page application).It will be all
Activity be confined in a Web page, only loaded when the Web page initializes corresponding HTML (HTML,
HyperText Mark-up Language), JavaScript and CSS (CSS, Cascading Style
Sheets).Once page loading completes, SPA will not carry out reloading or redirecting for the page because of the operation of user.Take
And instead of be dynamically to convert HTML content using JavaScript, so as to realize user interface (UI, User
Interface) interacted with user.Due to avoiding reloading for the page, SPA can provide more smooth user's body
Test.
In the prior art, directly embedded resource content or external connection resource file generally are carried out using html tag, or, make
Application programming interface (API, Application Programming Interface) is dynamic possessed by some browsers
The label of the generation respective resources of state is simultaneously inserted among document to guide browser to carry out the download of resource.
In the above prior art, when downloading resource file, it will block rendering for full page, and interruption pair simultaneously
The response of user mutual can just recover rendering for the page until respective resources file is loaded and is parsed, also, it is non-first
When loading resource file, even if resource file does not update, browser still needs to send enough requests to obtain money
The content in source, Internet resources are taken when requested more, reduce efficiency, and, load and fail if there is a certain resource, then may
Cause page layout entanglement, interaction failure.
The content of the invention
In view of this, the present invention provides a kind of front end resource loading method and device, is pulled by client concurrent request
Front end resource, and the ability that is locally stored using the client, improve it is non-load when use the client first needed for front end
The speed of resource, reduce the shared flow of loading, and reduce when client renders webpage due to loading the front end resource and
Caused by render interruption rate.
The embodiment of the present invention provides a kind of front end resource loading method, including:
Client obtains and parses the web document of targeted sites, comprising front end resource to be loaded in the web document
Description information;
According to the description information of the front end resource to be loaded, judge whether that the front end money to be loaded is being locally stored
Source;
If so, then read the front end resource to be loaded and be added into the web document, if it is not, then being asked to server
The front end resource to be loaded is downloaded, the front end resource to be loaded of download is added into the web document;
Displaying is added into the web document of the front end resource to be loaded.
The embodiment of the present invention provides a kind of front end resource loading device, including:
Acquisition module, for obtaining the web document of targeted sites, front end resource to be loaded is included in the web document
Description information;
Parsing module, the web document of the targeted sites obtained for parsing the acquisition module;
Judge module, for the description information according to the front end resource to be loaded, judge whether be locally stored
State front end resource to be loaded;
Read module, if judging the front end resource to be loaded is being locally stored for the judge module, read
The front end resource to be loaded;
Add module, the front end resource to be loaded being locally stored for the read module to be read are added into institute
State web document;
Request module, if judging locally be not stored with the front end resource to be loaded for the judge module, to
The front end resource to be loaded is downloaded in server request;
The add module, it is additionally operable to the front end resource to be loaded of download being added into the web document;
Display module, the web document of the front end resource to be loaded is added into for showing.
A kind of the front end resource loading method and device provided according to above-described embodiment, by client according to web document
In the description information of front end resource to be loaded that includes, judge locally whether be stored with the front end resource to be loaded, if so, then
Directly from locally reading the front end resource to be loaded and being added into the web document, treated if it is not, then downloading this to server request
Loading front end resource simultaneously adds the web document, can improve it is non-load when use the client first needed for front end resource speed
Degree, reduce flow and take.
For the above and other objects, features and advantages of the present invention can be become apparent, preferred embodiment cited below particularly,
And coordinate institute's accompanying drawings, it is described in detail below.
Brief description of the drawings
Fig. 1 is the applied environment figure of resource loading method in front end provided in an embodiment of the present invention and device.
Fig. 2 is a kind of structural representation of mobile terminal;
Fig. 3 is the flow chart for the front end resource loading method that first embodiment of the invention provides;
Fig. 4 is the flow chart for the front end resource loading method that second embodiment of the invention provides;
Fig. 5 is the structural representation for the front end resource loading device that third embodiment of the invention provides;
Fig. 6 is the structural representation for the front end resource loading device that fourth embodiment of the invention provides.
Embodiment
Further to illustrate that the present invention is to realize technological means and effect that predetermined goal of the invention taken, below in conjunction with
Accompanying drawing and preferred embodiment, to embodiment, structure, feature and its effect according to the present invention, describe in detail as after.
Fig. 1 is the applied environment figure of resource loading method in front end provided in an embodiment of the present invention and device.As shown in figure 1,
Mobile terminal 100 is located in wired or wireless network with server 200, and data interaction is carried out by the wired or wireless network,
To realize the front end resource loading method of following embodiment offer.
Front end resource loading method in the present invention can be applicable to single-page WEB (webpage) APP based on HTML5
Among (Application, application program), the APP can be the client-side program in mobile terminal device, i.e. user
This hair can be utilized when using the APP by the mobile terminal device including smart mobile phone, tablet personal computer, notebook computer etc.
Front end resource loading method in bright loads to the front end resource in the web document of targeted sites.
Technical scheme has following require for hardware and software environment:
Possess the terminal device of network access capacity, and, compatible HTML5javaScript API browser kernel.
Front end resource in the embodiment of the present invention refers to the single-page WEB APP minimums required in smooth perform
Gather, usually javaScript source files, CSS source files.
Specifically, mobile terminal 100 is obtained by client and parses the web document of targeted sites, in the web document
The description information of front end resource to be loaded is included, then according to the description information of the front end resource to be loaded, is judged whether at this
Ground is stored with the front end resource to be loaded, and when the front end resource to be loaded has been locally stored, reads the front end money to be loaded
Source is simultaneously added into the web document, and the web document for being added into the front end resource to be loaded is illustrated in into mobile terminal 100
On screen, and when not locally being stored with the front end resource to be loaded, download the front end to be loaded to the request of server 200 and provide
Source, the front end resource to be loaded of download is added into the web document, the webpage of the front end resource to be loaded will be added into
Document display is on the screen of mobile terminal 100.
Referring to Fig. 2, Fig. 2 is a kind of structural representation of mobile terminal.
Mobile terminal 100 includes memory 102, storage control 104, one or more (one is only shown in figure) processing
Device 106, Peripheral Interface 108, radio-frequency module 110, locating module 112, photographing module 114, audio-frequency module 116, Touch Screen 118
And key-press module 120.These components are mutually communicated by one or more communication bus/signal wire 122.
It is appreciated that structure shown in Fig. 2 is only to illustrate, mobile terminal 100 may also include it is more more than shown in Fig. 2 or
Less component, or there is the configuration different from shown in Fig. 2.Each component shown in Fig. 2 can use hardware, software or its
Combination is realized
Memory 102 can be used for storage software program and module, as in the embodiment of the present invention in mobile terminal
Programmed instruction/module corresponding to front end resource loading method and device, processor 106 are stored in memory 102 by operation
Software program and module, so as to perform various function application and data processing, i.e., by installed in above-mentioned mobile terminal
Interior client realizes front end resource loading method.
Memory 102 may include high speed random access memory, may also include nonvolatile memory, such as one or more magnetic
Property storage device, flash memory or other non-volatile solid state memories.In some instances, memory 102 can further comprise
Relative to the remotely located memory of processor 106, these remote memories can pass through network connection to terminal device 100.
The example of above-mentioned network includes but is not limited to internet, intranet, LAN, mobile radio communication and combinations thereof.Processor
306 and access of other possible components to memory 102 can be carried out under the control of storage control 304.
Various input/output devices are coupled to CPU and memory 102 by Peripheral Interface 108.The operation of processor 106 is deposited
Various softwares in reservoir 102, instruction are to perform the various functions of terminal device 100 and carry out data processing.
In certain embodiments, Peripheral Interface 108, processor 106 and storage control 104 can be in one single chips
Realize.In some other example, they can be realized by independent chip respectively.
Radio-frequency module 110 is used to receiving and sending electromagnetic wave, realizes the mutual conversion of electromagnetic wave and electric signal, so that with
Communication network or other equipment are communicated.Radio-frequency module 110 may include the various existing electricity for being used to perform these functions
Circuit component, for example, antenna, RF transceiver, digital signal processor, encryption/deciphering chip, subscriber identity module (SIM) card,
Memory etc..Radio-frequency module 110 can be communicated or led to various networks such as internet, intranet, wireless network
Wireless network is crossed to be communicated with other equipment.Above-mentioned wireless network may include cellular telephone networks, WLAN or
Metropolitan Area Network (MAN).Above-mentioned wireless network can use various communication standards, agreement and technology, and including but not limited to the whole world is mobile logical
Letter system (Global System for Mobile Communication, GSM), enhanced mobile communication technology
(Enhanced Data GSM Environment, EDGE), Wideband CDMA Technology (wideband code division
Multiple access, W-CDMA), CDMA (Code division access, CDMA), TDMA
(time division multiple access, TDMA), bluetooth, adopting wireless fidelity technology (Wireless, Fidelity,
WiFi) (such as American Institute of Electrical and Electronics Engineers's standard IEEE 802.11a, IEEE 802.11b, IEEE802.11g and/or
IEEE 802.11n), the networking telephone (Voice over internet protocal, VoIP), worldwide interoperability for microwave accesses
(Worldwide Interoperability for Microwave Access, Wi-Max), other be used for mail, IMU
The agreement of news and short message, and any other suitable communications protocol, or even may include that those are not developed currently yet
Agreement.
Locating module 112 is used for the current location for obtaining terminal device 100.The example of locating module 112 includes but unlimited
In GPS (GPS), the location technology based on WLAN or mobile radio communication.
Photographing module 114 is used to shoot photo or video.The photo or video of shooting can be stored to memory 102
It is interior, and can be sent by radio-frequency module 110.
Audio-frequency module 116 provides a user COBBAIF, and it may include one or more microphones, one or more raises
Sound device and voicefrequency circuit.Voicefrequency circuit receives voice data at Peripheral Interface 108, and voice data is converted into power information,
Power information is transmitted to loudspeaker.Loudspeaker is converted to power information the sound wave that human ear can hear.Voicefrequency circuit is also from microphone
Place receives power information, converts electrical signals to voice data, and by data transmission in network telephony into Peripheral Interface 108 to enter traveling one
The processing of step.Voice data can obtain at memory 102 or by radio-frequency module 110.In addition, voice data can also
Store into memory 102 or be transmitted by radio-frequency module 110.In some instances, audio-frequency module 116 may also include
One earphone broadcasts hole, for providing COBBAIF to earphone or other equipment.
Touch Screen 118 provides an output and inputting interface simultaneously between mobile terminal device 100 and user.Specifically
Ground, Touch Screen 118 show video frequency output to user, the contents of these video frequency outputs may include word, figure, video and its
Any combination.Some output results correspond to some user interface objects.Touch Screen 118 also receives the input of user, example
The click of such as user, gesture operation is slided, so that input of the user interface object to these users responds.Detect user
The technology of input can be based on resistance-type, condenser type or other any possible touch control detection technologies.Touch Screen 118 is aobvious
Show that the instantiation of unit includes but is not limited to liquid crystal display or light emitting polymer displays.
Key-press module 120 equally provides user's interface inputted to mobile terminal device 100, user can by by
Lower different button is so that terminal device movement 100 performs different functions.
First embodiment
Referring to Fig. 3, a kind of front end resource loading method provided for first embodiment of the invention, can be applied to Fig. 1 institutes
In the mobile terminal 100 shown, client-based front end resource loading is realized, this method includes:
S101, client obtain and parse the web document of targeted sites, are provided in the web document comprising front end to be loaded
The description information in source;
User accesses the WEB APP of installation on the client, and for ease of description, the embodiment of the present invention is with installed in intelligent hand
Exemplified by browser APP on machine.
User access browser APP, browser APP are obtained and are parsed the web document of targeted sites, wherein, targeted sites
Can be website corresponding to the resource content in browser APP homepages, the web document can be html document.The web document
In include the description information of front end resource to be loaded.The front end resource to be loaded is that a single-page WEB APP is smoothly being performed
When required minimal set, usually javaScript source files, CSS source files.The description information is to be added for describing this
Carry mark, property and the feature of front end resource.
S102, the description information according to the front end resource to be loaded, judge whether that the front end to be loaded is being locally stored
Resource;
According to the description information, judge whether be stored with the front end resource to be loaded in the local of client.
If so, then performing step S103, step S105 is then performed;If it is not, then performing step S104, step is then performed
S105。
S103, read the front end resource to be loaded and be added into the web document;
If the front end resource to be loaded has been locally stored, after locally the front end resource to be loaded is read, added
Enter in the web document.
S104, the download front end resource to be loaded is asked to server, the front end resource to be loaded of download is added into
The web document;
If local be not stored with the front end resource to be loaded, sent to server 200 and download the front end resource to be loaded
Request, front end resource to be loaded that the reception server 200 returns in response to the request, and by the front end to be loaded of download
Resource is added into the web document.
S105, displaying are added into the web document of the front end resource to be loaded.
Browser APP by all front end resources to be loaded after the web document is added into, by performing preset industry
Business starts code, business corresponding to execution (e.g., webpage renders business etc.), the web document is illustrated in the screen of smart mobile phone
On curtain.
The present embodiment provide front end resource loading method, by client according to included in web document it is to be loaded before
The description information of resource is held, judges locally whether be stored with the front end resource to be loaded, if so, then directly should from local read
Front end resource to be loaded is simultaneously added into the web document, if it is not, then asking to download the front end resource to be loaded and adding to server
Enter the web document, the speed of non-front end resource needed for loading when using the client first can be improved, flow is reduced and take.
Second embodiment
Referring to Fig. 4, providing a kind of front end resource loading method for second embodiment of the invention, Fig. 1 institutes are can be applied to
In the mobile terminal 100 shown, client-based front end resource loading is realized, this method includes:
S201, client obtain and parse the web document of targeted sites, are provided in the web document comprising front end to be loaded
The description information in source;
User access browser APP, browser APP are obtained by http protocol and are parsed the web document of targeted sites,
Wherein, targeted sites are website corresponding to the resource content in browser APP homepages, and the web document can be html document.
The description information of front end resource to be loaded is included in the web document.The front end resource to be loaded is a single-page WEB APP
The required minimal set in smooth perform, usually javaScript source files, CSS source files.The description information is used for
Mark, property and the feature of the front end resource to be loaded are described.Specifically, the description information includes:The front end resource to be loaded
Title, version number and storage address, the version number is typically issuing time stamp, and the storage address can be used for seeking survival
Store up the front end resource to be loaded in the storage address.
S202, check the local title identical local resource whether being stored with the front end resource to be loaded;
The title of the front end resource to be loaded in the description information, viewing client-side local (namely it is mobile eventually
End 100 is local) whether it is stored with title identical local resource with the front end resource to be loaded.
It should be noted that the technical scheme in the present embodiment is to be used as storage by the use of localStorage (being locally stored)
Media, most browsers all support localStorage as this technology of storage media, so in user by browsing
Without having to worry about incompatible situation when device APP is accessed.When searching the resource that matching is locally stored, resource name lookup is first passed through
Whether corresponding resource is had in localStorage.
If so, then perform step S203, check the local resource version number whether the version with the front end resource to be loaded
This number identical;If it is not, step S205 is then performed, it is determined that not being stored with the front end resource to be loaded in the local of the client.
S203, check whether the version number of the local resource is identical with the version number of the front end resource to be loaded;
The version number of the front end resource to be loaded in the description information, check the client be locally stored with
The front end resource to be loaded have the local resource of same names version number whether the version with the front end resource to be loaded
It is number identical.
If so, then performing step S204, it is determined that the front end resource to be loaded has been locally stored in the client, then hold
Row step S206;If it is not, step S205 is then performed, it is determined that the front end resource to be loaded is not stored with the local of the client,
Then step S207 is performed.
S204, determine that the front end resource to be loaded has been locally stored in the client;
Title and version number when the front end resource to be loaded in the description information, view mobile terminal
100 be locally stored with the title of the front end resource to be loaded and version number all identical local resource when, it is determined that at this
The front end resource to be loaded has been locally stored in client.
S205, determine not being stored with the front end resource to be loaded in the local of the client;
Title and version number when the front end resource to be loaded in the description information, do not view mobile terminal
100 be locally stored with the title of the front end resource to be loaded and version number all identical local resource when, that is, when movement
The title of the title for the local resource that terminal 100 is locally stored and the front end resource to be loaded differs, although or the two
Title is identical, but during the version number's difference of the two, it is determined that the front end resource to be loaded is not stored with the local of client.
S206, if it is determined that the front end resource to be loaded has been locally stored in the client, then read the front end to be loaded
Resource is simultaneously added into the web document;
If it is determined that the front end resource to be loaded has been locally stored in the client, then it is directly to be loaded from locally this is read
Front end resource simultaneously adds (loading) and enters the web document.
S207, if it is determined that be not stored with the front end resource to be loaded in the local of the client, then under being asked to server
The front end resource to be loaded is carried, the front end resource to be loaded of download is added into the web document;
If it is determined that not being stored with the front end resource to be loaded in the local of the client, then browser APP is utilized asynchronous
JavaScript and XML (AJAX, Asynchronous Javascript And XML) send request to server 200, with from
The front end resource to be loaded is pulled on server 200.It is to be appreciated that server 200 can be individual server or server
Cluster, namely the front end resource to be loaded can all be stored in a server or disperse to be stored in different servers
In.
Further,, can when asking to download the front end resource to be loaded to server because network environment is more complicated
To monitor server in real time to asking the responsive state of the front end resource to be loaded, when response timeout or the failure of request, weight
The front end resource to be loaded is downloaded in new request.So as to when resource loads failure, retry automatically, loading mortality is reduced.Yu Yi
In example, the responsive state availability status word for asking the front end resource to be loaded is obtained.
In the present embodiment, the afterbody of the web document includes generation corresponding to the mode for loading the front end resource to be loaded
Code, that is, code corresponding to the mode that will load the front end resource to be loaded is placed in the afterbody of the web document, can so allow
Browser APP is not disrupted as far as possible when parsing the web document, so as to accelerate the page layout response time.
Further, by performing the code for the afterbody for being placed in the web document, if downloading the front end resource to be loaded
Quantity is multiple, then multiple front end resources to be loaded of download is added into the web document according to the sequencing of request.
It is to be appreciated that if the request that the quantity for the front end resource to be loaded downloaded to be multiple, downloads the front end resource to be loaded can be with
To be multiple parallel, to improve speed of download, but after multiple front end resources to be loaded are downloaded to, then according to the sequencing of request
Multiple front end resource additions (loading) to be loaded of download are entered into the web document, to ensure there is the different to be added of dependence
Carry the dependence between the resource of front end.Such as:Assuming that 4 front end resource A, B, C, D to be loaded, wherein B are included in the web document
Correct loading depend on A correct loading, C correct loading depends on B correct loading, and browser APP is according to A, B, C, D
Sequencing download above-mentioned 4 front end resources to be loaded to the request of each server simultaneously, although because each front end to be loaded provides
The difference of the size of data in source and the network transfer speeds between each server, the order for completing to download is B, A, C, D, but clear
Above-mentioned 4 front end resources to be loaded still can be added into the web document by the device APP that lookes at according to A, B, C, D sequencing, be made
B, C will not cause unnecessary loading to fail because being loaded in advance, so that it is guaranteed that all front end resources to be loaded can be by
Smoothly loading, improve loading efficiency.
Further, after downloading the front end resource to be loaded, updated corresponding in being locally stored in local, including renewal
Resource content and version number in case next time loading when use, with it is further reduce load the response time.
S208, displaying are added into the web document of the front end resource to be loaded.
Browser APP by all front end resources to be loaded after the web document is added into, by performing preset industry
Business starts code, business corresponding to execution (e.g., webpage renders business etc.), the web document is illustrated in the screen of smart mobile phone
On curtain.
By the loading front end resource allocation method provided in above-described embodiment, loading front end resource has higher stability,
Lower data traffic, and faster response speed.
The present embodiment provide loading front end resource allocation method, by client according to included in web document it is to be loaded before
The description information of resource is held, judges locally whether be stored with the front end resource to be loaded, if so, then directly should from local read
Front end resource to be loaded is simultaneously added into the web document, if it is not, then asking to download the front end resource to be loaded and adding to server
Enter the web document, the speed of non-front end resource needed for loading when using the client first can be improved, flow is reduced and take.Enter
One step, code corresponding to the mode that will load the front end resource to be loaded is placed in the afterbody of the web document, can load
The influence that renders of the resource file loading to the page is reduced during resource file, reduces webpage and the interruption rate of user mutual.Also,
When asking to download front end resource to the server, snoop responses state, when response timeout or the failure of request, re-request
The front end resource to be loaded is downloaded, i.e., when resource loads failure, retries automatically, loading mortality can be reduced.
3rd embodiment
Referring to Fig. 5, provide a kind of front end resource loading device for third embodiment of the invention.As shown in figure 5, front end
Resource loading device 40 includes:
Acquisition module 401, for obtaining the web document of targeted sites, front end resource to be loaded is included in the web document
Description information;
Parsing module 402, the web document of the targeted sites for parsing the acquisition of acquisition module 401;
Judge module 403, for the description information according to the front end resource to be loaded, judge whether that this is being locally stored
Front end resource to be loaded;
Read module 404, if judging the front end resource to be loaded is being locally stored for judge module 403, read
The front end resource to be loaded;
Add module 405, front end resource to be loaded being locally stored for read module 404 to be read are added into this
Web document;
Request module 406, if judging locally be not stored with the front end resource to be loaded for judge module 403, to
The front end resource to be loaded is downloaded in server request;
Add module 405, it is additionally operable to the front end resource to be loaded of download being added into the web document;
Display module 407, the web document of the front end resource to be loaded is added into for showing.
The present embodiment refers to the detailed process of the respective function of each Implement of Function Module of front end resource loading device 40
Particular content described in each embodiment shown in above-mentioned Fig. 1 to Fig. 4, here is omitted.
The front end resource loading device that the present embodiment provides, by according to the front end resource to be loaded included in web document
Description information, judge locally whether be stored with the front end resource to be loaded, if so, then to read this to be loaded directly from local
Front end resource is simultaneously added into the web document, if it is not, then asking to download the front end resource to be loaded to server and adding the net
Page document, the speed of non-front end resource needed for loading when use the client first can be improved, reduces flow occupancy.
Fourth embodiment
A kind of referring to Fig. 6, front end resource loading device provided for fourth embodiment of the invention.As shown in fig. 6, front end
Resource loading device 50 includes:
Acquisition module 501, for obtaining the web document of targeted sites, front end resource to be loaded is included in the web document
Description information;
Parsing module 502, the web document of the targeted sites for parsing the acquisition of acquisition module 501;
Judge module 503, for the description information according to the front end resource to be loaded, judge whether that this is being locally stored
Front end resource to be loaded;
Read module 504, if judging the front end resource to be loaded is being locally stored for judge module 503, read
The front end resource to be loaded;
Add module 505, front end resource to be loaded being locally stored for read module 504 to be read are added into this
Web document;
Request module 506, if judging locally be not stored with the front end resource to be loaded for judge module 503, to
The front end resource to be loaded is downloaded in server request;
Add module 505, it is additionally operable to the front end resource to be loaded of download being added into the web document;
Display module 507, the web document of the front end resource to be loaded is added into for showing.
Further, the description information of the front end resource to be loaded includes the title of the front end resource to be loaded, version number
And storage address.
Further, judge module 503 includes:
Module 5031 is checked, for local whether be stored with and the title identical of the front end resource to be loaded local to be checked
Resource;
Module 5031 is checked, is locally provided with the title identical of the front end resource to be loaded if being additionally operable to be locally stored
Source, then check whether the version number of the local resource is identical with the version number of the front end resource to be loaded;
Determining module 5032, if locally being provided with the title identical of the front end resource to be loaded for local be not stored with
Source, it is determined that be not stored with the front end resource to be loaded in the local of client;
Determining module 5032, if being additionally operable to version number and the version number's phase of the front end resource to be loaded of the local resource
Together, it is determined that the front end resource to be loaded has been locally stored in the client;
Determining module 5032, if being additionally operable to the version number of the version number of the local resource and the front end resource to be loaded not phase
Together, it is determined that be not stored with the front end resource to be loaded in the local of the client.
Further, the afterbody of the web document includes code corresponding to the mode for loading the front end resource to be loaded.
Further, add module 505, it is additionally operable to by performing the code, if downloading the front end resource to be loaded
Quantity to be multiple, then multiple front end resources to be loaded of download are added into the webpage according to the sequencing of request
Document.
Further, front end resource loading device 50 also includes:
Module 508 being monitored, during for asking to download the front end resource to be loaded to server, monitoring the response shape of request
State, when response timeout or the failure of request, re-request downloads the front end resource to be loaded.
Further, front end resource loading device 50 also includes:
Update module 509, for by the front end resource updates to be loaded in local.
The present embodiment refers to the detailed process of the respective function of each Implement of Function Module of front end resource loading device 40
Particular content described in each embodiment shown in above-mentioned Fig. 1 to Fig. 4, here is omitted.
The front end resource loading device that the present embodiment provides, by according to the front end resource to be loaded included in web document
Description information, judge locally whether be stored with the front end resource to be loaded, if so, then to read this to be loaded directly from local
Front end resource is simultaneously added into the web document, if it is not, then asking to download the front end resource to be loaded to server and adding the net
Page document, the speed of non-front end resource needed for loading when use the client first can be improved, reduces flow occupancy.Further
Ground, code corresponding to the mode that will load the front end resource to be loaded are placed in the afterbody of the web document, can be in loading resource
The influence that renders of the resource file loading to the page is reduced during file, reduces webpage and the interruption rate of user mutual.Also, to
When front end resource is downloaded in server request, snoop responses state, when response timeout or the failure of request, re-request is downloaded
The front end resource to be loaded, i.e., when resource loads failure, retry automatically, loading mortality can be reduced.
It should be noted that each embodiment in this specification is described by the way of progressive, each embodiment weight
Point explanation is all difference with other embodiment, between each embodiment identical similar part mutually referring to.
For device class embodiment, because it is substantially similar to embodiment of the method, so description is fairly simple, related part is joined
See the part explanation of embodiment of the method.
It should be noted that herein, such as first and second or the like relational terms are used merely to a reality
Body or operation make a distinction with another entity or operation, and not necessarily require or imply and deposited between these entities or operation
In any this actual relation or order.Moreover, term " comprising ", "comprising" or its any other variant are intended to
Nonexcludability includes, so that process, method, article or device including a series of elements not only will including those
Element, but also the other element including being not expressly set out, or it is this process, method, article or device also to include
Intrinsic key element.In the absence of more restrictions, the key element limited by sentence "including a ...", it is not excluded that
Other identical element also be present in process, method, article or device including key element.
One of ordinary skill in the art will appreciate that hardware can be passed through by realizing all or part of step of above-described embodiment
To complete, can also by program come instruct correlation hardware complete, program can be stored in a kind of computer-readable storage
In medium, storage medium mentioned above can be read-only storage, disk or CD etc..
More than, only it is presently preferred embodiments of the present invention, any formal limitation not is made to the present invention, although this
Invention is disclosed above with preferred embodiment, but is not limited to the present invention, any person skilled in the art,
Do not depart from the range of technical solution of the present invention, when the technology contents using the disclosure above make a little change or are modified to equivalent
The equivalent embodiment of change, as long as being without departing from technical solution of the present invention content, the technical spirit according to the present invention is real to more than
Any simple modification, equivalent change and modification that example is made is applied, in the range of still falling within technical solution of the present invention.
Claims (10)
- A kind of 1. front end resource loading method, it is characterised in that including:Client is obtained and parses the web document of targeted sites, and the description of front end resource to be loaded is included in the web document Information;According to the description information of the front end resource to be loaded, judge whether that the front end resource to be loaded is being locally stored;If so, then read the front end resource to be loaded and be added into the web document, if it is not, then asking to download to server The front end resource to be loaded, wherein, if the quantity for the front end resource to be loaded downloaded is multiple, download described to be loaded The request of front end resource is multiple parallel, and the front end resource to be loaded of download is added into the web document, including:It is logical Execution code is crossed, if the quantity for downloading the front end resource to be loaded is multiple, according to the sequencing of request by download Multiple front end resources to be loaded are added into the web document, wherein, the afterbody of the web document is included described in loading The code corresponding to the mode of front end resource to be loaded;Displaying is added into the web document of the front end resource to be loaded.
- 2. according to the method for claim 1, it is characterised in that the description information of the front end resource to be loaded includes described Title, version number and the storage address of front end resource to be loaded.
- 3. according to the method for claim 2, it is characterised in that described to be believed according to the description of the front end resource to be loaded Breath, judges whether the client includes the front end resource to be loaded has been locally stored:Check the local title identical local resource whether being stored with the front end resource to be loaded;If so, then check whether the version number of the local resource is identical with the version number of the front end resource to be loaded, if it is not, Then determine not being stored with the front end resource to be loaded in the local of the client;If the version number of the local resource is identical with the version number of the front end resource to be loaded, it is determined that in the client The front end resource to be loaded has been locally stored, if the version of the version number of the local resource and the front end resource to be loaded This number differs, it is determined that is not stored with the front end resource to be loaded in the local of the client.
- 4. according to the method for claim 1, it is characterised in that methods described also includes:When asking to download the front end resource to be loaded to server, the responsive state of request is monitored;When response timeout or the failure of request, re-request downloads the front end resource to be loaded.
- 5. according to the method for claim 4, it is characterised in that described to download the front end money to be loaded to server request Also include after source:By the front end resource updates to be loaded in local.
- A kind of 6. front end resource loading device, it is characterised in that including:Acquisition module, for obtaining the web document of targeted sites, retouching for front end resource to be loaded is included in the web document State information;Parsing module, the web document of the targeted sites obtained for parsing the acquisition module;Judge module, for the description information according to the front end resource to be loaded, judge whether that described treat is being locally stored Load front end resource;Read module, if judging be locally stored the front end resource to be loaded for the judge module, read described in Front end resource to be loaded;Add module, the front end resource to be loaded being locally stored for the read module to be read are added into the net Page document;Request module, if judging locally be not stored with the front end resource to be loaded for the judge module, to service The front end resource to be loaded is downloaded in device request, wherein, if the quantity for the front end resource to be loaded downloaded is multiple, download The request of the front end resource to be loaded is multiple parallel;The add module, it is additionally operable to the front end resource to be loaded of download being added into the web document, including:Pass through Code is performed, if the quantity for downloading the front end resource to be loaded is multiple, according to the sequencing of request by the more of download The individual front end resource to be loaded is added into the web document, wherein, the afterbody of the web document includes to be treated described in loading Load the code corresponding to the mode of front end resource;Display module, the web document of the front end resource to be loaded is added into for showing.
- 7. device according to claim 6, it is characterised in that the description information of the front end resource to be loaded includes described Title, version number and the storage address of front end resource to be loaded.
- 8. device according to claim 7, it is characterised in that the judge module includes:Module is checked, for checking the local title identical local resource whether being stored with the front end resource to be loaded;It is described to check module, if being additionally operable to that the title identical local resource with the front end resource to be loaded is locally stored, Then check whether the version number of the local resource is identical with the version number of the front end resource to be loaded;Determining module, if for not being stored with the title identical local resource with the front end resource to be loaded locally, really The local for being scheduled on client is not stored with the front end resource to be loaded;The determining module, if being additionally operable to version number and the version number's phase of the front end resource to be loaded of the local resource Together, it is determined that the front end resource to be loaded has been locally stored in the client;The determining module, if being additionally operable to the version number of the version number of the local resource and the front end resource to be loaded not phase Together, it is determined that be not stored with the front end resource to be loaded in the local of the client.
- 9. device according to claim 6, it is characterised in that described device also includes:Module being monitored, during for asking to download the front end resource to be loaded to server, monitoring the responsive state of request, when please When the response timeout asked or failure, re-request downloads the front end resource to be loaded.
- 10. device according to claim 9, it is characterised in that described device also includes:Update module, for by the front end resource updates to be loaded in local.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510075489.3A CN104965848B (en) | 2015-02-12 | 2015-02-12 | A kind of front end resource loading method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510075489.3A CN104965848B (en) | 2015-02-12 | 2015-02-12 | A kind of front end resource loading method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104965848A CN104965848A (en) | 2015-10-07 |
CN104965848B true CN104965848B (en) | 2018-01-23 |
Family
ID=54219884
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510075489.3A Active CN104965848B (en) | 2015-02-12 | 2015-02-12 | A kind of front end resource loading method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104965848B (en) |
Families Citing this family (16)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105447198A (en) * | 2015-12-30 | 2016-03-30 | 深圳市瑞铭无限科技有限公司 | Convenient page script importing method and device |
CN107436899A (en) * | 2016-05-26 | 2017-12-05 | 阿里巴巴集团控股有限公司 | The implementation method and device of the vivo identification page |
CN107844332A (en) * | 2016-09-20 | 2018-03-27 | 天脉聚源(北京)科技有限公司 | A kind of method and system of mobile webpage loading external resource |
CN108460053A (en) * | 2017-02-20 | 2018-08-28 | 平安科技(深圳)有限公司 | File memory method and device |
CN107256151B (en) * | 2017-05-27 | 2020-09-11 | 北京小米移动软件有限公司 | Page rendering processing method and device and terminal |
CN113536174A (en) * | 2017-06-23 | 2021-10-22 | 创新先进技术有限公司 | Interface loading method, device and equipment |
CN107273528A (en) * | 2017-06-28 | 2017-10-20 | 努比亚技术有限公司 | A kind of front and back end separation method, mobile terminal and computer-readable recording medium |
CN107357876A (en) * | 2017-07-06 | 2017-11-17 | 校脸科技(北京)有限公司 | A kind of web access methods and device |
CN107678820B (en) * | 2017-09-29 | 2021-08-24 | 北京金山安全软件有限公司 | Webpage processing method, device, server, terminal equipment and medium |
CN110858240A (en) * | 2018-08-14 | 2020-03-03 | 北京京东尚科信息技术有限公司 | Front-end module loading method and device |
CN110096663A (en) * | 2019-03-18 | 2019-08-06 | 中国平安人寿保险股份有限公司 | Page loading method, device, electronic equipment and computer readable storage medium |
CN111581555B (en) * | 2020-04-27 | 2023-09-15 | 北京字节跳动网络技术有限公司 | Document loading method, device, equipment and storage medium |
CN112559927B (en) * | 2020-12-23 | 2023-01-03 | 上海哔哩哔哩科技有限公司 | Webpage loading method and device |
CN112965756B (en) * | 2021-01-21 | 2023-09-26 | 北京达佳互联信息技术有限公司 | Page resource loading amount monitoring method and device, electronic equipment and storage medium |
CN117574015A (en) * | 2023-12-05 | 2024-02-20 | 北京中宏立达科技发展有限公司 | Webpage updating method and device, electronic equipment and storage medium |
CN117880537A (en) * | 2023-12-06 | 2024-04-12 | 上海百秋新网商数字科技有限公司 | Interface-free all-channel E-commerce content management system and data reading method thereof |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102323890A (en) * | 2011-08-23 | 2012-01-18 | 百度在线网络技术(北京)有限公司 | The web page processing method, the Apparatus and system that are used for wireless terminal |
CN103218434A (en) * | 2013-04-15 | 2013-07-24 | 北京小米科技有限责任公司 | Method and device for loading static resource |
CN103699674A (en) * | 2013-12-31 | 2014-04-02 | 优视科技有限公司 | Webpage storing method, webpage opening method, webpage storing device, webpage opening device and webpage browsing system |
CN103873502A (en) * | 2012-12-11 | 2014-06-18 | 阿里巴巴集团控股有限公司 | Cache updating method and system, and update resource providing method and system |
-
2015
- 2015-02-12 CN CN201510075489.3A patent/CN104965848B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102323890A (en) * | 2011-08-23 | 2012-01-18 | 百度在线网络技术(北京)有限公司 | The web page processing method, the Apparatus and system that are used for wireless terminal |
CN103873502A (en) * | 2012-12-11 | 2014-06-18 | 阿里巴巴集团控股有限公司 | Cache updating method and system, and update resource providing method and system |
CN103218434A (en) * | 2013-04-15 | 2013-07-24 | 北京小米科技有限责任公司 | Method and device for loading static resource |
CN103699674A (en) * | 2013-12-31 | 2014-04-02 | 优视科技有限公司 | Webpage storing method, webpage opening method, webpage storing device, webpage opening device and webpage browsing system |
Also Published As
Publication number | Publication date |
---|---|
CN104965848A (en) | 2015-10-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104965848B (en) | A kind of front end resource loading method and device | |
CN105302587B (en) | Data-updating method and device | |
CN107741844B (en) | Method and device for generating application installation package | |
US10136298B2 (en) | Device-to-device content delivery method through interworking with service control apparatus | |
CN107656768B (en) | Method and system for controlling page jump | |
CN104424241B (en) | Web site url processing method based on two dimensional code, apparatus and system | |
TW201441829A (en) | Client side page processing | |
JP2014519632A (en) | Customized launch of application | |
CN105264821A (en) | Methods and apparatus for generating a message for a wireless device | |
WO2015070816A1 (en) | Application program push method, apparatus, device and system | |
CN104239332A (en) | Webpage content processing method, webpage content processing device and browser client side | |
CN112312222A (en) | Video sending method and device and electronic equipment | |
CN105681561A (en) | Advertisement blocking device and method | |
US9582584B2 (en) | Method, apparatus and system for filtering data of web page | |
CN108763297B (en) | Webpage resource processing method and device and mobile terminal | |
CN103607431B (en) | Mobile terminal resource processing method, device and equipment | |
WO2018137528A1 (en) | Method and device for accessing resource | |
CN108182090A (en) | Flash plug-in loading methods and device based on blink kernels | |
CN108370500B (en) | Optimized settings for wireless devices | |
CN110020338A (en) | Browser, webpage deployment method and equipment | |
CN104182331A (en) | Browser performance test method, browser performance test system and terminal | |
US10977425B1 (en) | Dynamic resource refresh | |
CN109145182B (en) | Data acquisition method and device, computer equipment and system | |
US10721289B2 (en) | Apparatus and method for improving loading time in electronic device | |
CN106294388B (en) | Page display method and terminal |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |