CN106775826B - Method and system for loading code file by annotation mode - Google Patents
Method and system for loading code file by annotation mode Download PDFInfo
- Publication number
- CN106775826B CN106775826B CN201611050662.5A CN201611050662A CN106775826B CN 106775826 B CN106775826 B CN 106775826B CN 201611050662 A CN201611050662 A CN 201611050662A CN 106775826 B CN106775826 B CN 106775826B
- Authority
- CN
- China
- Prior art keywords
- code file
- annotation
- code
- downloading
- files
- 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
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Transfer Between Computers (AREA)
Abstract
The invention relates to the field of browser application, and discloses a method for loading a code file by using an annotation mode, which comprises the following steps: step S1: downloading the code file to a browser and executing, wherein a note is defined in the code file associated with other code files, and the note contains a download address pointing to the associated code file; step S2: judging whether an annotation is defined in the code file; step S3: if yes, the code file pointed by the annotation is downloaded to the browser and executed, and then the process returns to step S2, otherwise, the process is ended. The invention also discloses a system for loading the code file by using the annotation mode. The invention can effectively improve the speed of loading the webpage by the browser.
Description
Technical Field
The invention relates to the field of browser application, in particular to a method for loading a code file by using an annotation mode and a system for loading the code file by using the annotation mode.
Background
The web pages of the browser often need some code files, such as some javascript files for implementing other functions, such as web page dynamics, and some css files for beautifying the style of the web page. Generally, when the browser parses the javascript file and the css file, it relies on < script > and < link > tags in the webpage, where < script > is used to inform the browser that the javascript file needs to be loaded, and < link > is used to inform the browser that the css file needs to be loaded.
However, with the development of diversification of web pages, the complexity of web pages is higher and higher, a large number of javascript files and css files are required to be used, functions of each javascript file or each css file are crossed, for example, the realization of a certain function in one javascript file needs to depend on a certain function in another javascript file, at this time, it is necessary to ensure that the dependent javascript file is loaded to realize a certain function of a web page, and with the complex relationship between the javascript files or the css files, the breakdown probability of the browser is greatly increased by adopting the analysis mode.
Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide a method for loading a code file by using an annotation mode and a system for loading the code file by using the annotation mode, which can effectively improve the speed of loading a webpage by a browser.
In order to achieve the above purposes, the technical scheme adopted by the invention is as follows:
step S1: downloading the code file to a browser and executing, wherein a note is defined in the code file associated with other code files, and the note contains a download address pointing to the associated code file;
step S2: judging whether an annotation is defined in the code file;
step S3: if yes, the code file pointed by the annotation is downloaded to the browser and executed, and then the process returns to step S2, otherwise, the process is ended.
On the basis of the technical scheme, the code files comprise javascript files and css files.
On the basis of the technical scheme, the annotation comprises a downloading mode of the code file pointed by the annotation.
On the basis of the technical scheme, the downloading mode comprises synchronous downloading and asynchronous downloading.
Based on the above technical solution, in step S1, the code file is downloaded to the browser in a synchronous downloading manner.
On the basis of the above technical solution, in step S3, before downloading the code file to which the annotation points, the method of downloading the code file in the annotation is determined:
if the code file is synchronously downloaded, the code file pointed by the annotation is downloaded in a synchronous downloading mode;
and if the code file is asynchronously downloaded, the code file pointed by the annotation is downloaded in an asynchronous downloading mode.
The invention also discloses a system for loading the code file by using the annotation mode, which comprises the following steps:
the loading module is used for downloading the code file to the browser;
and the judging module is used for judging whether the code file defines the annotation, and if so, the judging module is also used for controlling the loading module to download the code file pointed by the annotation to the browser.
On the basis of the technical scheme, the code files comprise javascript files and css files.
On the basis of the technical scheme, the annotation comprises a downloading mode and a downloading address of the code file, and the downloading mode comprises synchronous downloading and asynchronous downloading.
On the basis of the technical scheme, the judging module is further used for judging the downloading mode of the code files in the annotations, if the code files are synchronously downloaded, the code files pointed by the annotations are downloaded in a synchronous downloading mode, and if the code files are asynchronously downloaded, the code files pointed by the annotations are downloaded in an asynchronous downloading mode.
Compared with the prior art, the method for loading the code file by using the annotation mode has the advantages that: the method adopts an annotation mode to manage the code files, and the annotation defined in the code files is used for indicating that when the current code files are executed, a browser is informed that other code files need to be loaded to cooperate with the current codes to realize other functions of the dynamic state of the webpage and the like, so that the < script > marks and the < link > marks in the webpage are greatly reduced, the relation logic among the code files is clear, the webpage loading speed of the browser is improved, the later maintenance difficulty of the webpage is reduced, and the workload of developers is reduced.
The system of the method for loading the code file by using the annotation mode has the advantages that: the code files are managed in an annotation mode, the code files pointed by the annotations are loaded according to the annotations in the code files, and the speed of loading the webpage by the browser is effectively improved.
Drawings
FIG. 1 is a flow chart of a method for loading a code file using annotation methods of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings.
Referring to fig. 1, the present invention provides a method for loading a code file in an annotation manner, which is used for loading a functional code file attached to a web page by a browser when the web page is browsed by the browser. The method of the invention comprises the following steps:
step S1: downloading the code file to a browser and executing, wherein the code file associated with other code files is defined with notes, the notes comprise download addresses pointing to the associated code files, and specifically, if the realization of the function of a certain code file needs to depend on other code files, the code file is associated with other code files, and the code file is defined with notes. The method for downloading the code file into the browser comprises synchronous downloading and asynchronous downloading, wherein the synchronous downloading is that when the browser carries out the downloading operation of the file, other programs in the browser are suspended, and after the file is downloaded, the other programs are continuously executed; asynchronous downloading is that when the browser is performing file downloading operation, other programs in the browser can continue to execute at the same time. In the step, a code file is downloaded to the browser in a synchronous downloading mode.
When the browser loads a webpage, javascript files which are not depended on by other javascript are correspondingly provided with < script > tags which are used for informing the browser that the javascript files need to be downloaded, css files which are not depended on by other css files are correspondingly provided with < link > tags which are used for informing the browser that the css files need to be downloaded.
The complete form of < script > mark is < script src ═ file address >, the < script > mark represents the address of the javascript file corresponding to the < script > mark, when the browser analyzes the webpage and identifies the < script > mark carried by the webpage, the src on the mark can be matched, so that the address of the javascript file is obtained, and the javascript file is downloaded to the browser.
The complete form of the < link > mark is < link href ═ file address >, where href ═ file address indicates the address of the css file corresponding to the < link > mark, when the browser analyzes the webpage and identifies the < link > mark carried by the webpage, the href on the mark is matched, so as to obtain the address of the jscs file, and the css file is downloaded to the browser.
Step S2: it is determined whether an annotation is defined in the code file.
The annotation includes a download mode and a download address of a code file to which the annotation points, and specifically, the annotation is used for managing a javascript file or a css file, and generally appears at the beginning of the javascript file or the css file, and the annotation includes: an essential "@" symbol, an essential annotation name, and optionally other information. The format is as follows:
/**
@ dependson javascript or css file address 1
*@async
@ dependson javascript or css file address 2
@ dependson javascript or css file address 3
*/
The @ async is used for indicating that the code file pointed by the @ dependedson at the lower part needs to be downloaded in an asynchronous downloading mode, and if the @ async does not exist, the code file pointed by the @ dependedson at the lower part needs to be downloaded in a synchronous downloading mode.
Step S3: if the code file does not define the annotation, ending; if the code file has the annotation, downloading the code file pointed by the annotation to the browser and executing the code file, then returning to the step S2, and before downloading the code file pointed by the annotation, determining the downloading mode of the code file in the annotation, if the code file is synchronously downloaded, downloading the code file pointed by the annotation in a synchronous downloading mode, and if the code file is asynchronously downloaded, downloading the code file pointed by the annotation in an asynchronous downloading mode.
Specifically, if the code file does not define the annotation, the operation is ended, that is, the code file is loaded into the browser, and no annotation defined in the code file is found in the execution process, and the operation on the code file is ended after the current code file is executed; if a code file is loaded into a browser and an annotation is defined in the code file in the execution process, parsing the annotation to obtain annotation information, if @ async is found in the parsed annotation information, a dependent file pointed by @ dependedson below the @ async in the annotation information, namely the code file pointed by the @ dependedson needs to be downloaded into the browser in an asynchronous downloading mode, wherein the @ dependedson comprises the following components: the @ annotation name + other information is obtained by intercepting the character string of the @ dependson to obtain a download address of the code file, then the browser reads the download address, downloads the code file to the browser in an asynchronous download mode and executes the code file, then the step S2 is carried out, circulation is carried out until no annotation is found to be defined in the code file, if the @ async is not found in the analyzed annotation information, a dependent file pointed by the @ dependson below the annotation information, namely the code file pointed by the annotation, needs to be downloaded to the browser in a synchronous download mode and executed, then the step S2 is carried out, circulation is carried out until no annotation is found to be defined in the code file.
The method manages the code file in an annotation mode, and notes defined in the code file are used for indicating that when the current code file is executed, a browser is informed that other code files need to be loaded to cooperate with the current code to realize certain functions of the webpage. If the current code is executed, and the definition of the annotation in the code file is found, loading the code file pointed by the annotation into a browser for execution, and judging whether the code file pointed by the annotation contains the annotation, if so, continuing to download the corresponding code file for execution and judging, and sequentially circulating until the code file does not contain the annotation any more, and finishing the execution process of the whole code file.
The code files are managed in an annotation mode, the code files which are not depended on by other code files are not needed, namely the code files which are matched with other code files to realize certain functions are correspondingly provided with < script > marks or < link > marks, the code files which are matched with each other to realize certain functions are code files which do not contain < script > marks or < link > marks, and the annotation of the former code files informs the browser of the latter code files which need to be recorded, so that the < script > marks and the < link > marks in the webpage are greatly reduced, the logic relation among the associated code files is clear, the webpage loading speed of the browser is improved, the later maintenance difficulty of the webpage is reduced, and the workload of developers is reduced.
The invention also comprises a system for loading the code file by using the annotation mode, which comprises a loading module and a judging module.
The loading module is used for downloading the code file to the browser; the judging module is used for judging whether the code file defines annotation, and if so, the judging module is also used for controlling the loading module to download the code file pointed by the annotation to the browser.
The code files comprise javascript files and css files, the annotations comprise download modes and download addresses of the code files, the download modes comprise synchronous download and asynchronous download, the judging module is further used for judging the download modes of the code files in the annotations, if the download modes are synchronous download, the code files pointed by the annotations are downloaded in a synchronous download mode, and if the download modes are asynchronous download, the code files pointed by the annotations are downloaded in an asynchronous download mode.
The code files are managed in an annotation mode, the code files pointed by the annotations are loaded according to the annotations in the code files, and the speed of loading the webpage by the browser is effectively improved.
The present invention is not limited to the above-described embodiments, and it will be apparent to those skilled in the art that various modifications and improvements can be made without departing from the principle of the present invention, and such modifications and improvements are also considered to be within the scope of the present invention. Those not described in detail in this specification are within the skill of the art.
Claims (7)
1. A method for loading a code file using annotation, comprising:
step S1: downloading the code file to a browser and executing, wherein a note is defined in the code file associated with other code files, and the note contains a download address pointing to the associated code file;
step S2: judging whether an annotation is defined in the code file;
step S3: if yes, downloading a code file pointed by the annotation to the browser and executing, then returning to the step S2, and if not, ending;
when the browser loads a webpage, javascript files which are not depended on by other javascript files correspond to < script > tags, css files which are not depended on by other css files correspond to < link > tags, and the annotations comprise a downloading mode of the code files pointed by the annotations.
2. A method of loading a code file using annotation processes as claimed in claim 1, wherein: the downloading mode comprises synchronous downloading and asynchronous downloading.
3. A method of loading a code file using annotation means as claimed in claim 2, wherein: in step S1, the code file is downloaded to the browser in a synchronous download manner.
4. A method of loading a code file using annotation means as claimed in claim 2, wherein: in step S3, before downloading the code file pointed by the annotation, the method of downloading the code file in the annotation is determined:
if the code file is synchronously downloaded, the code file pointed by the annotation is downloaded in a synchronous downloading mode;
and if the code file is asynchronously downloaded, the code file pointed by the annotation is downloaded in an asynchronous downloading mode.
5. A system for loading a code file using an annotation schema based on the method of claim 1, comprising:
the loading module is used for downloading the code file to the browser;
and the judging module is used for judging whether the code file defines the annotation, and if so, the judging module is also used for controlling the loading module to download the code file pointed by the annotation to the browser.
6. The system for loading a code file using an annotation process of claim 5, wherein: the annotation comprises a downloading mode and a downloading address of the code file, wherein the downloading mode comprises synchronous downloading and asynchronous downloading.
7. The system for loading a code file using an annotation process of claim 5, wherein: the judging module is also used for judging the downloading mode of the code files in the annotations, if the code files are synchronously downloaded, the code files pointed by the annotations are downloaded in a synchronous downloading mode, and if the code files are asynchronously downloaded, the code files pointed by the annotations are downloaded in an asynchronous downloading mode.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611050662.5A CN106775826B (en) | 2016-11-22 | 2016-11-22 | Method and system for loading code file by annotation mode |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611050662.5A CN106775826B (en) | 2016-11-22 | 2016-11-22 | Method and system for loading code file by annotation mode |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106775826A CN106775826A (en) | 2017-05-31 |
CN106775826B true CN106775826B (en) | 2020-12-15 |
Family
ID=58912756
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201611050662.5A Active CN106775826B (en) | 2016-11-22 | 2016-11-22 | Method and system for loading code file by annotation mode |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106775826B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108170756B (en) * | 2017-12-22 | 2021-12-03 | 南京邮电大学 | Implementation method of multidimensional, multi-view and visual annotation system based on Git warehouse |
CN108228231B (en) * | 2018-01-08 | 2021-07-27 | 南京邮电大学 | Visualization drifting method of Git warehouse file annotation system |
CN112784270A (en) * | 2021-01-18 | 2021-05-11 | 仙境文化传媒(武汉)有限公司 | System and method for loading code file by annotation mode |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1808439A (en) * | 2006-02-21 | 2006-07-26 | 西安迪戈科技有限责任公司 | Method of adding searchable deep labels in web pages in conjunction with browser plug-ins and scripts |
US20090132949A1 (en) * | 2007-11-16 | 2009-05-21 | Jason Bosarge | Methods and systems for transmitting, receiving and annotating internet content |
US20120257249A1 (en) * | 2011-04-08 | 2012-10-11 | Sundaram Natarajan | Cloud and html based fax and document management system |
CN104317941A (en) * | 2014-10-31 | 2015-01-28 | 新华瑞德(北京)网络科技有限公司 | Resource injection method and device of applications |
CN105677326A (en) * | 2015-12-28 | 2016-06-15 | 国云科技股份有限公司 | Software interface parameter validation method |
-
2016
- 2016-11-22 CN CN201611050662.5A patent/CN106775826B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1808439A (en) * | 2006-02-21 | 2006-07-26 | 西安迪戈科技有限责任公司 | Method of adding searchable deep labels in web pages in conjunction with browser plug-ins and scripts |
US20090132949A1 (en) * | 2007-11-16 | 2009-05-21 | Jason Bosarge | Methods and systems for transmitting, receiving and annotating internet content |
US20120257249A1 (en) * | 2011-04-08 | 2012-10-11 | Sundaram Natarajan | Cloud and html based fax and document management system |
CN104317941A (en) * | 2014-10-31 | 2015-01-28 | 新华瑞德(北京)网络科技有限公司 | Resource injection method and device of applications |
CN105677326A (en) * | 2015-12-28 | 2016-06-15 | 国云科技股份有限公司 | Software interface parameter validation method |
Also Published As
Publication number | Publication date |
---|---|
CN106775826A (en) | 2017-05-31 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11403364B2 (en) | Method and terminal device for extracting web page content | |
CN104461484B (en) | The implementation method and device of front-end template | |
CN109388766B (en) | Page loading method and device | |
US9182953B2 (en) | Hybrid dynamic code compiling device, method, and service system thereof | |
CN106909361B (en) | Web development method and device based on template engine | |
CN104731589A (en) | Automatic generation method and device of user interface (UI) | |
CN106775826B (en) | Method and system for loading code file by annotation mode | |
KR101787527B1 (en) | Framework supporting apparatus for developing client application under multi-platform environment, and method using the same | |
CN102741811A (en) | Improving performance of template based JavaScript widgets | |
WO2017081558A1 (en) | Monitoring and actuation of view controller parameters to reach deep states without manual developer intervention | |
CN102880708A (en) | Visual design system and method for implementing hypertext markup language (HTML) page | |
CN103412754A (en) | Dynamic language code execution method and device | |
CN111427583A (en) | Component compiling method and device, electronic equipment and computer readable storage medium | |
CN108885544B (en) | Front-end page internationalized processing method, application server and computer-readable storage medium | |
CN102955852A (en) | Method, device and equipment for webpage resource processing | |
CN110020370B (en) | Method and device for realizing animation in client application and framework of animation script | |
CN105159900B (en) | Multi-medium data edit methods and editing machine | |
CN105022667A (en) | Embedded browser CSS (Cascading Style Sheets) based engine parallelization method | |
US20130080876A1 (en) | Using a template processor to determine context nodes | |
CA2602749C (en) | System and method of report representation | |
CN112199626A (en) | Dynamic form generation method based on DSL layout engine | |
CN112416533A (en) | Method and device for running application program on browser and electronic equipment | |
WO2016005886A2 (en) | Self-referencing of running script elements in asychronously loaded dom modules | |
CN106293862B (en) | A kind of analysis method and device of expandable mark language XML data | |
CN105607909A (en) | Method and system for improving list development efficiency on basis of MVC frame |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |