CN104572230B - Script file loading method and device and script file generating method and device - Google Patents

Script file loading method and device and script file generating method and device Download PDF

Info

Publication number
CN104572230B
CN104572230B CN201510080503.9A CN201510080503A CN104572230B CN 104572230 B CN104572230 B CN 104572230B CN 201510080503 A CN201510080503 A CN 201510080503A CN 104572230 B CN104572230 B CN 104572230B
Authority
CN
China
Prior art keywords
script file
file
browser
new
single process
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510080503.9A
Other languages
Chinese (zh)
Other versions
CN104572230A (en
Inventor
谭国斌
马哲
沈建荣
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xiaomi Inc
Original Assignee
Xiaomi Inc
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 Xiaomi Inc filed Critical Xiaomi Inc
Priority to CN201510080503.9A priority Critical patent/CN104572230B/en
Publication of CN104572230A publication Critical patent/CN104572230A/en
Application granted granted Critical
Publication of CN104572230B publication Critical patent/CN104572230B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Transfer Between Computers (AREA)

Abstract

The disclosure relates to a script file loading method, a script file generating method and a device, which are used for avoiding a blocking phenomenon generated in a process of loading a script file by a browser. The loading method of the script file comprises the following steps: when a browser needs to load a script file, sending a file list of the script file to a cache server, and informing the browser to execute a task in a single process in an asynchronous loading mode; receiving a new script file generated by the cache server according to the file list; and informing the browser to stop executing the task in the single process, and loading the new script file through the single process. The technical scheme of the invention can effectively avoid the blocking phenomenon generated in the process of loading the script file.

Description

Script file loading method and device and script file generating method and device
Technical Field
The present disclosure relates to the field of network technologies, and in particular, to a script file loading method, a script file generating method, and an apparatus.
Background
The browser processes a User Interface (UI) and updates Javascript (js) to run and other tasks by using a single process, and because the single process can only execute one task at the same time, how long the Javascript runs, and how long the browser waits, the page of the whole browser is in a waiting state due to parsing, running and the like of the js script in the process of loading the js script file by the browser, that is, in the process of loading the js script, the page parsing of the browser and the interaction between the browser and the user are completely blocked, for the user, the webpage of the browser is in a 'false death' state, and at the moment, the user cannot interact with the browser.
Disclosure of Invention
In order to overcome the problems in the related art, embodiments of the present disclosure provide a method for loading a script file, a method for generating a script file, and a device, so as to avoid a blocking phenomenon occurring in a process of loading a script file by a browser.
According to a first aspect of the embodiments of the present disclosure, there is provided a method for loading a script file, which is applied to a terminal device, and includes:
when a browser needs to load a script file, sending a file list of the script file to a cache server, and informing the browser to execute a task in a single process in an asynchronous loading mode;
receiving a new script file generated by the cache server according to the file list;
and loading the new script file through the single process.
In an embodiment, the functional logic relationship in the new script file may be determined by the functional logic relationship between the script files to be loaded, and the loading the new script file through the single process may include:
and loading the new script file through the single process according to the function logic relationship in the new script file.
According to a second aspect of the embodiments of the present disclosure, there is provided a script file generating method, applied to a cache server, including:
receiving a file list of script files needing to be loaded by a browser;
determining a new script file to be loaded by the browser according to the file list, wherein the function logic relationship of the new script file is consistent with the function logic relationship of the script file to be loaded;
and sending the new script file to the browser.
In an embodiment, the determining a new script file that needs to be loaded by the browser according to the file list may include:
detecting whether a script file in the file list is stored on the cache server or not;
if the cache server stores the script files in the file list, generating a new script file to be loaded by the browser according to the file list;
and if the cache server does not store the script file in the file list, acquiring the new script file from a web server.
In one embodiment, the obtaining the new script file from the web server may include:
sending the file list to the web server;
and receiving the new script file generated by the web server according to the file list.
According to a third aspect of the embodiments of the present disclosure, there is provided a device for loading a script file, which is applied to a terminal device, and includes:
the system comprises a first sending module, a second sending module and a cache server, wherein the first sending module is configured to send a file list of a script file to the cache server when the browser needs to load the script file, and inform the browser of executing a task in a single process in an asynchronous loading mode;
the first receiving module is configured to receive a new script file generated by the cache server according to the file list sent by the first sending module;
and the loading module is configured to inform the browser to stop executing the task in the single process, and load the new script file received by the first receiving module through the single process.
In an embodiment, the functional logic relationship in the new script file may be determined by the functional logic relationship between the script files to be loaded, and the loading module may include:
and the loading submodule is configured to load the new script file through the single process according to the functional logic relationship in the new script file received by the first receiving module.
According to a fourth aspect of the embodiments of the present disclosure, there is provided a device for generating a script file, which is applied to a cache server, and includes:
the second receiving module is configured to receive a file list of script files needing to be loaded by the browser;
the determining module is configured to determine a new script file which needs to be loaded by the browser according to the file list received by the second receiving module, and the functional logic relationship of the new script file is consistent with that of the script file which needs to be loaded;
a second sending module configured to send the new script file determined by the determining module to the browser.
In an embodiment, the determining module may include:
the detection submodule is configured to detect whether the script file in the file list received by the second receiving module is stored on the cache server;
the generating submodule is configured to generate a new script file to be loaded by the browser according to the file list if the detecting submodule detects that the cache server stores the script file in the file list;
and the obtaining sub-module is configured to obtain the new script file from a web server if the detection sub-module detects that the cache server does not store the script file in the file list.
In one embodiment, the obtaining sub-module may include:
a transmitting sub-module configured to transmit the file list to the web server;
a receiving submodule configured to receive the new script file generated by the web server according to the file list sent by the sending submodule.
According to a fifth aspect of the embodiments of the present disclosure, there is provided a device for loading a script file, including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to:
when a browser needs to load a script file, sending a file list of the script file to a cache server, and informing the browser to execute a task in a single process in an asynchronous loading mode;
receiving a new script file generated by the cache server according to the file list;
and informing the browser to stop executing the task in the single process, and loading the new script file through the single process.
According to a sixth aspect of the embodiments of the present disclosure, there is provided a script file generating apparatus including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to:
receiving a file list of script files needing to be loaded by a browser;
determining a new script file to be loaded by the browser according to the file list, wherein the function logic relationship of the new script file is consistent with the function logic relationship of the script file to be loaded;
and sending the new script file to the browser.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects: when the browser needs to load the script file, because the browser can still execute the task in the single process in an asynchronous loading mode, and because the browser is not always waiting for loading the script file which the browser needs to load currently, but can also continue to execute the tasks such as page analysis and the like in the single process, the interaction between the browser and the user is normal; only when a new script file is received, the browser stops executing the task in the single process, and loads the new script file through the single process, and the loading process of the whole script file does not enable the browser to be in a waiting process, so that the blocking phenomenon generated in the process of loading the script file can be effectively avoided.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
FIG. 1 is a flowchart illustrating a method of loading a script file according to an exemplary embodiment.
FIG. 2 is a flowchart illustrating a method of loading a script file, according to an example embodiment.
FIG. 3 is a flowchart illustrating a script file generation method in accordance with an exemplary embodiment.
FIG. 4A is a flowchart illustrating a script file generation method in accordance with an exemplary embodiment.
FIG. 4B is a scene diagram illustrating a script file generation method according to an exemplary embodiment.
FIG. 5 is a block diagram illustrating a means for loading a script file according to an example embodiment.
Fig. 6 is a block diagram illustrating another apparatus for loading a script file according to an example embodiment.
Fig. 7 is a block diagram illustrating a script file generating apparatus according to an example embodiment.
Fig. 8 is a block diagram illustrating another script file generating apparatus according to an example embodiment.
Fig. 9 is a block diagram illustrating a loading apparatus adapted for use with a script file according to an example embodiment.
Fig. 10 is a block diagram illustrating a script file generating apparatus according to an example embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.
Fig. 1 is a flowchart illustrating a loading method of a script file according to an exemplary embodiment, where the flowchart of the loading method of the script file illustrated in fig. 1 is applicable to a terminal device (e.g., a smart phone, a tablet computer, a PC, etc.), and can be implemented on a browser on the terminal device, as illustrated in fig. 1, the loading method of the script file includes the following steps S101-S103:
in step S101, when the browser needs to load the script file, a file list of the script file is sent to the cache server, and the browser is notified to execute the task in the single process in an asynchronous loading manner.
In an embodiment, for example, when the browser needs to load three script files, i.e., file1.js, file2.js, and file3.js, the file names of the three script files may be sent to a cache server (or a Content Delivery Network (CDN)) with the closest communication distance according to the current IP address of the browser; in an embodiment, the names of the three script files may be sent in a file list manner, so that the cache server or the CDN determines to return the script file that can be loaded by the browser to the terminal device according to the file list.
In an embodiment, other js files of a single process can be dynamically and asynchronously loaded through the jsloader, for example, the other js files are script files for rendering a webpage, so that the browser can realize the operations such as rendering the webpage without waiting for loading and executing the three script files, the webpage is prevented from being in a 'false death' state, and the real-time performance of interaction between the browser and a user is improved.
In step S102, a new script file generated by the cache server according to the file list is received.
In one embodiment, the new script file may be generated from the script files in the file list; in one embodiment, the cache server may determine the logical relationship of the new script file according to the calling relationship between the script files in the file list.
In step S103, the browser is notified to stop executing the task in the single process, and a new script file is loaded through the single process.
In an embodiment, for example, when a browser needs to load file1.js, file2.js, and file3.js, an implementation process of the related art is that when file1.js needs to be loaded, file1.js needs to be acquired from a cache server, then the file is loaded, when file2.js needs to be recorded, file2.js needs to be acquired from the cache server, then the file is loaded, and when file3.js needs to be recorded, file3.js is acquired from the cache server, and then the file is loaded, so that three times of interaction with the cache server needs to be performed, and in the case where the browser is a single-process processing task, the process of loading file1.js, file2.js, and file3.js is very long, whereas the script file script of the present disclosure can avoid sending the time and the recording time of the cache file needing to be loaded to the server by loading a new script file in a plurality of script files needing to be loaded by the browser.
In this embodiment, when the browser needs to load a script file, since the browser can still execute a task in a single process in an asynchronous loading manner, since the browser is not waiting to load the script file that the browser needs to load currently, but can also continue to execute tasks such as page parsing and the like in the single process, the interaction between the browser and the user is normal; only when a new script file is received, the browser stops executing the task in the single process, and loads the new script file through the single process, and the loading process of the whole script file does not enable the browser to be in a waiting process, so that the blocking phenomenon generated in the process of loading the script file can be effectively avoided.
In an embodiment, the functional logic relationship in the new script file may be determined by the functional logic relationship between the script files that need to be loaded, and step S102 may include:
and loading the new script file through a single process according to the function logic relation in the new script file.
Please refer to the following embodiments for details of how to load a script file on a browser.
Therefore, the method provided by the embodiment of the disclosure can effectively avoid the blocking phenomenon generated in the process of loading the script file.
The technical solutions provided by the embodiments of the present disclosure are described below with specific embodiments.
FIG. 2 is a flowchart of an illustrative method of loading a script file in accordance with an illustrative embodiment; the present embodiment uses the above method provided by the embodiment of the present disclosure to exemplarily explain by loading a script file on a browser, as shown in fig. 2, the method includes the following steps:
in step S201, when the browser needs to load the script file, a file list of the script file is sent to the cache server, and the browser is notified to execute the task in the single process in an asynchronous loading manner.
The description of step S201 may refer to the description of step S101 above, and will not be described in detail here.
In step S202, a new script file generated by the cache server according to the file list is received.
The description of step S202 may refer to the description of step S102 above, and will not be described in detail here.
In step S203, the browser is notified to stop executing the task in the single process, and the new script file is loaded according to the functional logic relationship in the new script file.
The description of step S203 may refer to the description of step S103 described above; in addition, in an embodiment, the new script file may be determined according to a functional logic relationship between the script files in the file list, so that the browser may load the new script file normally; in one embodiment, the functional logical relationship may be determined from the relationship between function calls in the script file.
Fig. 3 is a flowchart illustrating a script file generating method according to an exemplary embodiment, where fig. 1 is a flowchart illustrating a script file loading method according to an exemplary embodiment, where the flowchart may be applied to a terminal device (e.g., a smart phone, a tablet computer, a PC, etc.), and may be implemented on a browser on the terminal device, as shown in fig. 1, the script file loading method includes the following steps S101-S103:
in step S301, a file list of script files that the browser needs to load is received.
In one embodiment, for example, when the browser requests the cache server to return three script files, i.e., file1.js, file2.js and file3.js, to be loaded in a file list manner, the cache server may determine which script files the browser needs to load from the file list.
In step S302, a new script file that needs to be loaded by the browser is determined according to the file list, and the functional logic relationship of the new script file is consistent with the functional logic relationship of the script file that needs to be loaded.
In an embodiment, if the cache server stores the script files in the file list, the cache server may merge the script files in the file list into a new script file according to the function call relationship or the logic relationship between the functions; in another embodiment, if the script file in the file list is not stored on the cache server, the cache server may send the file list to the web server and obtain the script file from the web server; in one embodiment, the web server may merge the script files into a new script file according to the function call relationship or the logic relationship between the functions according to the file list, and in another embodiment, the web server may transmit the script files in the file list to the cache server, and the cache server merges the script files into a new script file according to the function call relationship or the logic relationship between the functions.
In step S303, the new script file is transmitted to the browser.
In this embodiment, by generating a new script file and sending the new script file to the browser, the browser stops executing the task in the single process, and loads the new script file through the single process, and because the loading process of the whole script file does not make the browser in the waiting process, the embodiment of the present disclosure can effectively avoid the blocking phenomenon generated in the process of loading the script file.
In one embodiment, step S302 may include:
detecting whether a script file in a file list is stored on a cache server or not;
if the cache server stores the script file in the file list, generating a new script file to be loaded by the browser according to the file list;
and if the cache server does not store the script file in the file list, acquiring a new script file from the web server.
In one embodiment, obtaining a new script file to a web server may include:
sending a file list to a web server;
and receiving a new script file generated by the web server according to the file list.
Please refer to the following embodiments for details of how to generate the script file.
Therefore, the method provided by the embodiment of the disclosure can effectively avoid the blocking phenomenon generated in the process of loading the script file.
The technical solutions provided by the embodiments of the present disclosure are described below with specific embodiments.
FIG. 4A is a flowchart illustrating a script file generation method in accordance with an illustrative embodiment, and FIG. 4B is a scene diagram illustrating a script file generation method in accordance with an illustrative embodiment; the present embodiment uses the above method provided by the embodiment of the present disclosure to exemplarily explain by loading a script file on a browser, as shown in fig. 4A, including the following steps:
in step S401, a file list of script files that the browser needs to load is received.
The description of step S401 may refer to the description of step S301 above and will not be described in detail here.
In step S402, it is detected whether a script file in the file list is stored on the cache server, if so, step S403 is executed, and if not, step S404 is executed.
In an embodiment, the cache server is located between the web servers (also referred to as content source servers) and the terminal device, the cache server may store a copy of the content sent by the web server to the terminal device according to the access request of the terminal device, where the copy is, for example, an html page, a picture, a file, and the like, when the cache server receives a next access request of the terminal device, if the URL of the current access request is the same as the URL of the previous access request, the cache server may directly respond to the current access request through the copy, instead of sending the access request again to the web server, so that the delay time for responding to the request may be reduced.
In step S403, if the cache server stores the script file in the file list, a new script file to be loaded by the browser is generated according to the file list, and step 406 is executed.
In one embodiment, the cache server may merge the script files in the file list into a new script file according to the function call relation or the logical relation between the functions.
In step S404, if the cache server does not store the script file in the file list, a new script file is acquired from the web server, and step S405 is executed.
In an embodiment, if the script file in the file list is not stored on the cache server, the cache server may send the file list to the web server, and obtain the script file from the web server; in one embodiment, the web server may merge the script files into a new script file according to the function call relationship or the logic relationship between the functions according to the file list, and in another embodiment, the web server may transmit the script files in the file list to the cache server, and the cache server merges the script files into a new script file according to the function call relationship or the logic relationship between the functions.
In step S405, the new script file is sent to the browser, and the process ends.
As shown in fig. 4B, the terminal device 41 may implement dynamic asynchronous loading of js files through jsloaders, and when a script file needs to be loaded, send a file list of the script file that needs to be loaded urgently to the cache server 42 (or the source content distribution network), for example, file1.js, file2.js, and file3.js files need to be loaded, and send the file names of the three script files to the cache server 42 in a file list manner.
After receiving the file list, the cache server 42 determines whether the script file in the file list is stored in the cache server 42, and if so, merges the script file in the file list into a new script file according to the functional logic relationship between the script file and the new script file, and returns the new script file to the browser on the terminal device 41.
If the script file in the file list is not stored in the cache server 42, the cache server 42 sends the file list to the web server 43, the web server 43 analyzes the script file in the file list, merges the script file in the file list into a new script file according to the functional logic relationship between the script file and the new script file, returns the new script file to the cache server 42, and the cache server 42 sends the new script file to the browser of the terminal device 41; alternatively, the web server 43 may directly return the script files in the file list to the cache server 42, and the cache server 42 generates a new script file according to the functional logic relationship between the script files in the file list and sends the new script file to the browser of the terminal device 41.
The browser of the terminal device 41 may stop the task being executed by the single process by loading the new script file.
In the embodiment, the new script file is generated and sent to the browser, the browser stops executing the task in the single process, and the new script file is loaded through the single process.
Fig. 5 is a block diagram illustrating a loading apparatus of a script file according to an exemplary embodiment, which is applied to a terminal device, and as shown in fig. 5, the loading apparatus of the script file may include:
a first sending module 51, configured to send a file list of the script file to the cache server when the browser needs to load the script file, and notify the browser to execute a task in a single process in an asynchronous loading manner;
a first receiving module 52 configured to receive a new script file generated by the cache server according to the file list sent by the first sending module 51;
and a loading module 53 configured to load the new script file received by the first receiving module 52 through a single process.
Fig. 6 is a block diagram illustrating another apparatus for loading a script file according to an exemplary embodiment, where, as shown in fig. 6, based on the embodiment shown in fig. 5, the functional logic relationship in the new script file may be determined by the functional logic relationship between the script files that need to be loaded, and the loading module 53 may include:
and the loading submodule 531 is configured to load the new script file through a single process according to the functional logic relationship in the new script file received by the first receiving module 52.
Fig. 7 is a block diagram of a script file generating apparatus according to an exemplary embodiment, which is applied to a cache server, and as shown in fig. 7, the script file loading apparatus includes:
a second receiving module 71, configured to receive a file list of script files that the browser needs to load;
a determining module 72 configured to determine, according to the file list received by the second receiving module 71, a new script file that needs to be loaded by the browser, where a functional logic relationship of the new script file is consistent with a functional logic relationship of the script file that needs to be loaded;
a second sending module 73 configured to send the new script file determined by the determining module 72 to the browser.
Fig. 8 is a block diagram illustrating another script file generating apparatus according to an exemplary embodiment, and as shown in fig. 8, the determining module 72 may include, based on the embodiment shown in fig. 7:
the detection sub-module 721 is configured to detect whether the script file in the file list received by the second receiving module 71 is stored on the cache server;
the generating submodule 722 is configured to, if the detecting submodule 721 detects that the cache server stores the script file in the file list, generate a new script file to be loaded by the browser according to the file list;
an obtaining sub-module 723 configured to obtain a new script file from the web server if the detecting sub-module 721 detects that the cache server does not store the script file in the file list.
In an embodiment, the obtaining sub-module 723 may include:
a transmitting sub-module 7231 configured to transmit the file list to the web server;
the receiving sub-module 7232 is configured to receive a new script file generated by the web server according to the file list transmitted by the transmitting sub-module 7231.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Fig. 9 is a block diagram illustrating an apparatus suitable for charging a portable device according to an example embodiment. For example, the apparatus 900 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 9, apparatus 900 may include one or more of the following components: processing component 902, memory 904, power component 906, multimedia component 908, audio component 910, input/output (I/O) interface 912, sensor component 914, and communication component 916.
The processing component 902 generally controls overall operation of the device 900, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. Processing element 902 may include one or more processors 920 to execute instructions to perform all or a portion of the steps of the methods described above. Further, processing component 902 can include one or more modules that facilitate interaction between processing component 902 and other components. For example, the processing component 902 can include a multimedia module to facilitate interaction between the multimedia component 908 and the processing component 902.
The memory 904 is configured to store various types of data to support operation at the device 900. Examples of such data include instructions for any application or method operating on device 900, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 904 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
Power component 906 provides power to the various components of device 900. The power components 906 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the device 900.
The multimedia component 908 comprises a screen providing an output interface between the device 900 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 908 includes a front facing camera and/or a rear facing camera. The front-facing camera and/or the rear-facing camera may receive external multimedia data when the device 900 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 910 is configured to output and/or input audio signals. For example, audio component 910 includes a Microphone (MIC) configured to receive external audio signals when apparatus 900 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 904 or transmitted via the communication component 916. In some embodiments, audio component 910 also includes a speaker for outputting audio signals.
I/O interface 912 provides an interface between processing component 902 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor component 914 includes one or more sensors for providing status assessment of various aspects of the apparatus 900. For example, the sensor assembly 914 may detect an open/closed state of the device 900, the relative positioning of the components, such as a display and keypad of the apparatus 900, the sensor assembly 914 may also detect a change in the position of the apparatus 900 or a component of the apparatus 900, the presence or absence of user contact with the apparatus 900, orientation or acceleration/deceleration of the apparatus 900, and a change in the temperature of the apparatus 900. The sensor assembly 914 may include a proximity sensor configured to detect the presence of a nearby object in the absence of any physical contact. The sensor assembly 914 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 914 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 916 is configured to facilitate communications between the apparatus 900 and other devices in a wired or wireless manner. The apparatus 900 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 916 receives a broadcast signal or broadcast associated information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communications component 916 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 900 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer readable storage medium comprising instructions, such as the memory 904 comprising instructions, executable by the processor 920 of the apparatus 900 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
FIG. 10 is a block diagram illustrating an apparatus suitable for controlling indicator lights installed on smart devices, according to an example embodiment. For example, the apparatus 1000 may be provided as a smart phone or tablet computer. Referring to fig. 10, the apparatus 1000 includes a processing component 1022 that further includes one or more processors and memory resources, represented by memory 1032, for storing instructions, such as application programs, that are executable by the processing component 1022. The application programs stored in memory 1032 may include one or more modules that each correspond to a set of instructions. Further, the processing component 1022 is configured to execute instructions to perform the above-described script file generation method.
The device 1000 may also include a power supply component 1026 configured to perform power management for the device 1000, a wired or wireless network interface 1050 configured to connect the device 1000 to a network, and an input/output (I/O) interface 1058. The apparatus 1000 may operate based on an operating system stored in memory 1032, such as Windows Server, MacOS XTM, UnixTM, LinuxTM, FreeBSDTM, or the like.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (12)

1. A loading method of a script file is applied to a terminal device, and is characterized in that the method comprises the following steps:
when a browser needs to load a script file, sending a file list of the script file to a cache server, and informing the browser to execute other tasks in a single process in an asynchronous loading mode;
receiving a new script file generated by the cache server according to the file list;
and informing the browser to stop executing other tasks in the single process, and loading the new script file through the single process.
2. The method according to claim 1, wherein the functional logic relationship in the new script file is determined by the functional logic relationship between the script files to be loaded, and the loading the new script file through the single process comprises:
and loading the new script file through the single process according to the function logic relationship in the new script file.
3. A method for generating a script file is applied to a cache server, and is characterized in that the method comprises the following steps:
receiving a file list of script files needing to be loaded by a browser; when the browser needs to load the script file, executing other tasks in the single process in an asynchronous loading mode;
determining a new script file to be loaded by the browser according to the file list, wherein the function logic relationship of the new script file is consistent with the function logic relationship of the script file to be loaded;
and sending the new script file to the browser so that the browser stops executing other tasks in the single process, and loading the new script file through the single process.
4. The method of claim 3, wherein determining a new script file that needs to be loaded by the browser according to the file list comprises:
detecting whether a script file in the file list is stored on the cache server or not;
if the cache server stores the script files in the file list, generating a new script file to be loaded by the browser according to the file list;
and if the cache server does not store the script file in the file list, acquiring the new script file from a web server.
5. The method of claim 4, wherein the obtaining the new script file from the web server comprises:
sending the file list to the web server;
and receiving the new script file generated by the web server according to the file list.
6. A loading device of script files is applied to terminal equipment, and is characterized in that the device comprises:
the system comprises a first sending module, a second sending module and a cache server, wherein the first sending module is configured to send a file list of a script file to the cache server when the browser needs to load the script file, and inform the browser of executing other tasks in a single process in an asynchronous loading mode;
the first receiving module is configured to receive a new script file generated by the cache server according to the file list sent by the first sending module;
and the loading module is configured to inform the browser to stop executing other tasks in the single process, and load the new script file received by the first receiving module through the single process.
7. The apparatus according to claim 6, wherein the functional logic relationship in the new script file is determined by the functional logic relationship between the script files to be loaded, and the loading module comprises:
and the loading submodule is configured to load the new script file through the single process according to the functional logic relationship in the new script file received by the first receiving module.
8. An apparatus for generating a script file, applied to a cache server, the apparatus comprising:
the second receiving module is configured to receive a file list of script files needing to be loaded by the browser; when the browser needs to load the script file, executing other tasks in the single process in an asynchronous loading mode;
the determining module is configured to determine a new script file which needs to be loaded by the browser according to the file list received by the second receiving module, and the functional logic relationship of the new script file is consistent with that of the script file which needs to be loaded;
a second sending module, configured to send the new script file determined by the determining module to the browser, so that the browser stops executing other tasks in the single process, and loads the new script file through the single process.
9. The apparatus of claim 8, wherein the determining module comprises:
the detection submodule is configured to detect whether the script file in the file list received by the second receiving module is stored on the cache server;
the generating submodule is configured to generate a new script file to be loaded by the browser according to the file list if the detecting submodule detects that the cache server stores the script file in the file list;
and the obtaining sub-module is configured to obtain the new script file from a web server if the detection sub-module detects that the cache server does not store the script file in the file list.
10. The apparatus of claim 9, wherein the acquisition submodule comprises:
a transmitting sub-module configured to transmit the file list to the web server;
a receiving submodule configured to receive the new script file generated by the web server according to the file list sent by the sending submodule.
11. An apparatus for loading a script file, the apparatus comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to:
when a browser needs to load a script file, sending a file list of the script file to a cache server, and informing the browser to execute other tasks in a single process in an asynchronous loading mode;
receiving a new script file generated by the cache server according to the file list;
and informing the browser to stop executing other tasks in the single process, and loading the new script file through the single process.
12. An apparatus for generating a script file, the apparatus comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to:
receiving a file list of script files needing to be loaded by a browser; when the browser needs to load the script file, executing other tasks in the single process in an asynchronous loading mode;
determining a new script file to be loaded by the browser according to the file list, wherein the function logic relationship of the new script file is consistent with the function logic relationship of the script file to be loaded;
and sending the new script file to the browser so that the browser stops executing other tasks in the single process, and loading the new script file through the single process.
CN201510080503.9A 2015-02-13 2015-02-13 Script file loading method and device and script file generating method and device Active CN104572230B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510080503.9A CN104572230B (en) 2015-02-13 2015-02-13 Script file loading method and device and script file generating method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510080503.9A CN104572230B (en) 2015-02-13 2015-02-13 Script file loading method and device and script file generating method and device

Publications (2)

Publication Number Publication Date
CN104572230A CN104572230A (en) 2015-04-29
CN104572230B true CN104572230B (en) 2020-02-07

Family

ID=53088388

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510080503.9A Active CN104572230B (en) 2015-02-13 2015-02-13 Script file loading method and device and script file generating method and device

Country Status (1)

Country Link
CN (1) CN104572230B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106055367B (en) * 2016-06-01 2021-06-18 腾讯科技(深圳)有限公司 Script file loading method and device
CN107844500A (en) * 2016-09-20 2018-03-27 天脉聚源(北京)科技有限公司 A kind of method and system of mobile terminal loading webpage
CN107623729B (en) * 2017-09-08 2021-01-15 华为技术有限公司 Caching method, caching equipment and caching service system
CN110209973B (en) * 2019-05-24 2021-03-19 厦门美柚股份有限公司 Webpage game loading method and device

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103530152A (en) * 2013-10-10 2014-01-22 小米科技有限责任公司 Method, device and terminal device for loading client-side scripts

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7689665B2 (en) * 2007-04-27 2010-03-30 Microsoft Corporation Dynamically loading scripts
CN103020226A (en) * 2012-12-12 2013-04-03 北京百度网讯科技有限公司 Method and device for acquiring search result
CN103269377B (en) * 2013-05-31 2016-08-24 北京奇虎科技有限公司 Process the method for script file, server, client and system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103530152A (en) * 2013-10-10 2014-01-22 小米科技有限责任公司 Method, device and terminal device for loading client-side scripts

Also Published As

Publication number Publication date
CN104572230A (en) 2015-04-29

Similar Documents

Publication Publication Date Title
CN109814965B (en) H5 page processing method and device, electronic equipment and storage medium
CN107229711B (en) Webpage display method and device
CN109274510B (en) Message processing method, device, client, server and storage medium
CN108833585B (en) Information interaction method and device and storage medium
CN105808305B (en) Static resource loading method and device
CN110262692B (en) Touch screen scanning method, device and medium
CN107071862B (en) Account number binding method and device and intelligent equipment
EP3147802B1 (en) Method and apparatus for processing information
CN111259289B (en) Picture loading method and device, electronic equipment and storage medium
CN109525652B (en) Information sharing method, device, equipment and storage medium
CN104572230B (en) Script file loading method and device and script file generating method and device
CN109117144B (en) Page processing method, device, terminal and storage medium
CN107729098B (en) User interface display method and device
CN112463418A (en) Cross-device information sharing method, device, medium and electronic device
CN113238881B (en) Page communication method and device
CN108984417B (en) Software testing method, device, terminal and storage medium
EP3425533A1 (en) Displaying page
CN107222576B (en) Photo album synchronization method and device
CN111079040B (en) Resource sniffing method, device, terminal, server and storage medium
CN109885360B (en) Data processing method, device and storage medium
CN109245992B (en) Request processing method and device, electronic equipment and storage medium
CN114339320B (en) Virtual resource processing method, device, equipment and storage medium
CN107026941B (en) Method and device for processing reply of unread message
CN112954596B (en) Data sharing method, device, equipment and storage medium
CN109981729B (en) File processing method and device, electronic equipment and computer readable storage medium

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