CN113568678A - Method and device for dynamically loading resources and electronic equipment - Google Patents

Method and device for dynamically loading resources and electronic equipment Download PDF

Info

Publication number
CN113568678A
CN113568678A CN202110804417.3A CN202110804417A CN113568678A CN 113568678 A CN113568678 A CN 113568678A CN 202110804417 A CN202110804417 A CN 202110804417A CN 113568678 A CN113568678 A CN 113568678A
Authority
CN
China
Prior art keywords
template
dynamic
resources
script
loading
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.)
Granted
Application number
CN202110804417.3A
Other languages
Chinese (zh)
Other versions
CN113568678B (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.)
Shanghai Qiyue Information Technology Co Ltd
Original Assignee
Shanghai Qiyue Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Qiyue Information Technology Co Ltd filed Critical Shanghai Qiyue Information Technology Co Ltd
Priority to CN202110804417.3A priority Critical patent/CN113568678B/en
Publication of CN113568678A publication Critical patent/CN113568678A/en
Application granted granted Critical
Publication of CN113568678B publication Critical patent/CN113568678B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a method, a device and electronic equipment for dynamically loading resources, which relate to the technical field of application starting and comprise the steps of obtaining a template library; compiling the template library into a compiled file directory, wherein the compiled file directory comprises hypertext markup language templates; and executing a templated task based on the hypertext markup language template, and dynamically loading a script. The method and the device can optimize the packing and constructing performance, accelerate the loading performance of the front-end page resources and prevent the problem that the loaded page resources are blocked due to the performance.

Description

Method and device for dynamically loading resources and electronic equipment
Technical Field
The present invention relates to the field of application startup technologies, and in particular, to a method and an apparatus for dynamically loading resources, and an electronic device.
Background
The modular construction means that necessary connection is established among a plurality of codes to form a module.
Generally, when modularly organizing code, modules are divided into different files and folders, and may also contain some third-party libraries such as read and undercore. All these modules then need to be introduced into your HTML file via tags, and then the user can just display and work properly when accessing your web page. Each separate tab means that they are loaded individually by the browser, which can result in a lengthy page loading time.
Therefore, a method, an apparatus and an electronic device for dynamically loading resources are provided.
Disclosure of Invention
The specification provides a method, a device and an electronic device for dynamically loading resources, so as to optimize packing and building performance, accelerate front-end page resource loading performance and prevent the problem that loaded page resources are jammed due to performance.
The method for dynamically loading the resources provided by the application adopts the following technical scheme that the method comprises the following steps:
acquiring a template library;
compiling the template library into a compiled file directory, wherein the compiled file directory comprises hypertext markup language templates;
and executing a templated task based on the hypertext markup language template, and dynamically loading a script.
Optionally, the compiling the template library into a compiled file directory includes:
compiling the template library into a hypertext markup language template;
and compiling the hypertext markup language template into a compiled file directory.
Optionally, the executing a templated task based on the hypertext markup language template and dynamically loading a script includes:
acquiring script resources and introducing a template;
generating a resource mapping list based on the hypertext markup language template;
loading the resource mapping list into a construction configuration item of a template packer;
searching out a corresponding introduction template from the introduction templates based on the construction configuration items;
parsing the hypertext markup language template into character data;
searching the corresponding introduction template based on the character data;
judging whether the corresponding method for introducing the template contains a dynamic introduction template or not, and replacing the dynamic introduction template with an array of dependent items when the judgment result is that the corresponding method contains the dynamic introduction template;
resolving the array dependent items into script resources which refer to dynamic functions;
and embedding the script resources for referring to the dynamic functions into the head of the dynamic import template, and pre-loading.
Optionally, the executing a templating task based on the hypertext markup language template and dynamically loading a script further includes:
acquiring script resources and introducing a template;
generating a resource mapping list based on the hypertext markup language template;
loading the resource mapping list into a construction configuration item of a template packer;
searching a dynamic import template and a template dependent item from the import template based on the construction configuration item, and forming a number group item by the dynamic import template and the template dependent item;
parsing the array items into incoming script characters;
replacing the dynamic import template with an array of dependent terms;
resolving the array dependent items into script resources which refer to dynamic functions;
and embedding script resources for referencing dynamic functions into the head of the dynamic import template, and pre-loading the script resources. Optionally, the determining whether the corresponding template importing method includes a dynamic template importing method further includes:
and when the judgment result is that the product does not contain:
searching the number of the corresponding introduction templates based on the character data;
judging whether the number of the corresponding template introducing methods is single or not, and replacing the dynamic introducing template into a plurality of groups of dependent items when the judgment result is not yes;
resolving the array dependent items into script resources which refer to dynamic functions;
and embedding the script resources for referring to the dynamic functions into the head of the dynamic import template, and pre-loading.
Optionally, the determining whether the number of the corresponding template introducing methods is single further includes:
when the judgment result is that:
replacing the corresponding import template with an array of dependencies;
confusing and compressing the corresponding introduced template to generate a new template;
compiling the new template into the compiled file directory.
Optionally, the resource mapping list includes an import template name, a page name, and a dependent script resource name.
The device for dynamically loading resources provided by the application adopts the following technical scheme that the device comprises:
the acquisition module is used for acquiring a template library;
the compiling module is used for compiling the template library into a compiling file directory, and the compiling file directory comprises a hypertext markup language template;
and the loading module is used for executing templating tasks based on the hypertext markup language template and dynamically loading scripts.
Optionally, the compiling module includes:
the first compiling unit is used for compiling the template library into a hypertext markup language template;
and the second compiling unit is used for compiling the hypertext markup language template into a compiled file directory.
Optionally, the loading module includes:
the acquisition unit is used for acquiring script resources and introducing templates;
the generating unit is used for generating a resource mapping list based on the hypertext markup language template;
the loading unit is used for loading the resource mapping list into a construction configuration item of the template packer;
the first searching unit is used for searching out a corresponding introduction template from the introduction templates based on the construction configuration items;
the first analysis unit is used for analyzing the hypertext markup language template into character data;
a second searching unit for searching the corresponding method of the import template based on the character data;
the judging unit is used for judging whether the corresponding method for introducing the template contains a dynamic introduction template or not, and when the judging result is that the method contains the dynamic introduction template, the dynamic introduction template is replaced by an array dependent item;
the second analysis unit is used for analyzing the array dependence items into script resources for quoting dynamic functions;
and the first embedding unit is used for embedding the script resource which refers to the dynamic function into the head of the dynamic import template and is preloaded.
Optionally, the loading module further includes:
the acquisition unit is used for acquiring script resources and introducing templates;
the generating unit is used for generating a resource mapping list based on the hypertext markup language template;
the loading unit is used for loading the resource mapping list into a construction configuration item of the template packer;
the third searching unit is used for searching out a dynamic import template and a template dependent item from the import template based on the construction configuration item, and forming the dynamic import template and the template dependent item into a plurality of groups of items;
a third parsing unit for parsing the array items into incoming script characters;
a replacement unit for replacing the dynamic import template with an array of dependent entries;
the fourth analysis unit is used for analyzing the array dependence items into script resources for quoting dynamic functions;
and the second embedding unit is used for embedding the script resource which refers to the dynamic function into the head of the dynamic import template and is preloaded.
Optionally, the determining unit further includes:
and when the judgment result is that the product does not contain:
searching the number of the corresponding introduction templates based on the character data;
judging whether the number of the corresponding template introducing methods is single or not, and replacing the dynamic introducing template into a plurality of groups of dependent items when the judgment result is not yes;
resolving the array dependent items into script resources which refer to dynamic functions;
and embedding the script resources for referring to the dynamic functions into the head of the dynamic import template, and pre-loading.
Optionally, the determining whether the number of the corresponding template introducing methods is single further includes:
when the judgment result is that:
replacing the corresponding import template with an array of dependencies;
confusing and compressing the corresponding introduced template to generate a new template;
compiling the new template into the compiled file directory.
Optionally, the resource mapping list includes an import template name, a page name, and a dependent script resource name.
The present specification also provides an electronic device, wherein the electronic device includes:
a processor; and the number of the first and second groups,
a memory storing computer-executable instructions that, when executed, cause the processor to perform any of the methods described above.
The present specification also provides a computer readable storage medium, wherein the computer readable storage medium stores one or more programs which, when executed by a processor, implement any of the methods described above.
The method comprises the steps of obtaining a template base, compiling the template base to obtain a hypertext markup language template, and generating a resource mapping list through the hypertext markup language template, wherein the resource mapping list comprises an introduction template name, a page name and a dependent script resource name. And a template packer at the front end reads the resource mapping list, processes the resources and compiles codes to obtain script resources and a dynamic introduction template which quote the dynamic functions, and embeds the script resources which quote the dynamic functions into the head of the dynamic introduction template to realize preloading and dynamic loading of scripts.
Drawings
FIG. 1 is a schematic diagram illustrating a method for dynamically loading resources according to an embodiment of the present disclosure;
fig. 2 is a schematic structural diagram of an apparatus for dynamically loading resources according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of an electronic device provided in an embodiment of the present disclosure;
fig. 4 is a schematic diagram of a computer-readable medium provided in an embodiment of the present specification.
Detailed Description
The following description is presented to disclose the invention so as to enable any person skilled in the art to practice the invention. The preferred embodiments in the following description are given by way of example only, and other obvious variations will occur to those skilled in the art. The basic principles of the invention, as defined in the following description, may be applied to other embodiments, variations, modifications, equivalents, and other technical solutions without departing from the spirit and scope of the invention.
The present application is described in further detail below with reference to figures 1-4.
An embodiment of the present specification provides a method for dynamically loading resources, including:
acquiring a template library;
compiling the template library into a compiled file directory, wherein the compiled file directory comprises hypertext markup language templates;
and executing a templated task based on the hypertext markup language template, and dynamically loading a script.
In the embodiment of the present specification, a template library is obtained, the template library is compiled to obtain a hypertext markup language template, and a resource mapping list is generated through the hypertext markup language template, where the resource mapping list includes an introduction template name, a page name, and a dependent script resource name. And a template packer at the front end reads the resource mapping list, processes the resources and compiles codes to obtain script resources and a dynamic introduction template which quote the dynamic functions, and embeds the script resources which quote the dynamic functions into the head of the dynamic introduction template to realize preloading and dynamic loading of scripts.
Exemplary embodiments of the present invention will now be described more fully with reference to the accompanying drawings. The exemplary embodiments, however, may be embodied in many different forms and should not be construed as limited to the embodiments set forth herein. Rather, these exemplary embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of the invention to those skilled in the art. The same reference numerals denote the same or similar elements, components, or parts in the drawings, and thus their repetitive description will be omitted.
Features, structures, characteristics or other details described in a particular embodiment do not preclude the fact that the features, structures, characteristics or other details may be combined in a suitable manner in one or more other embodiments in accordance with the technical idea of the invention.
In describing particular embodiments, the present invention has been described with reference to features, structures, characteristics or other details that are within the purview of one skilled in the art to provide a thorough understanding of the embodiments. One skilled in the relevant art will recognize, however, that the invention may be practiced without one or more of the specific features, structures, characteristics, or other details.
The flow charts shown in the drawings are merely illustrative and do not necessarily include all of the contents and operations/steps, nor do they necessarily have to be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
The block diagrams shown in the figures are functional entities only and do not necessarily correspond to physically separate entities. I.e. these functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor means and/or microcontroller means.
The term "and/or" and/or "includes all combinations of any one or more of the associated listed items.
Fig. 1 is a schematic diagram of a method for dynamically loading a resource according to an embodiment of the present disclosure, where the method may include:
s101: and acquiring a template library.
In the present specification embodiment, the Template library includes an EJS Template library, a Template7 Template library, and the like. The EJS template library, Embedded JavaScript mapping, is a JavaScript template library used for generating HTML (HyperText Markup Language) character strings from JSON (JavaScript Object Notation) data. The Template library of Template7 is a mobile device priority JavaScript Template engine with a Handlebars (a semantic Template library of JavaScript, which quickly constructs a Web Template by separating view and data) class grammar.
S102: compiling the template library into a compiled file directory, the compiled file directory including hypertext markup language templates.
In the embodiment of the present specification, the template library is output to the compiled file directory through an ordered build model, where the ordered build model includes GULP, Grunt, and the like. GULP, General Utility Program, is an automated building tool that developers can use to automatically perform common tasks during the development of a project. Grunt, as a front-end construction tool, has the functions of resource compression, code inspection, file merging and the like. The compiled file directory includes a Dist directory, a Dest directory, and the like. The Dist directory is used for storing compiled or compressed codes and finally releasing the codes of versions. Dest directory, compressed package folder. The hypertext Markup Language template includes an HTML (hypertext Markup Language) template.
In an embodiment of the present specification, the compiling the template library into the compiled file directory includes:
compiling the template library into a hypertext markup language template;
and compiling the hypertext markup language template into a compiled file directory.
In the embodiment of the specification, the EJS template library is compiled into an HTML template through GULP, and then the HTML template is compiled into a Dist directory through GULP.
S103: and executing a templated task based on the hypertext markup language template, and dynamically loading a script.
In the embodiment of the specification, the HTML template is read, the HTML template is matched with the introduced template, a templating task is executed, and finally, preloading and dynamic script loading are realized.
In an embodiment of the present specification, the executing a templated task based on the hypertext markup language template, dynamically loading a script, includes:
acquiring script resources and introducing a template;
generating a resource mapping list based on the hypertext markup language template;
loading the resource mapping list into a construction configuration item of a template packer;
searching out a corresponding introduction template from the introduction templates based on the construction configuration items;
parsing the hypertext markup language template into character data;
searching the corresponding introduction template based on the character data;
judging whether the corresponding method for introducing the template contains a dynamic introduction template or not, and replacing the dynamic introduction template with an array of dependent items when the judgment result is that the corresponding method contains the dynamic introduction template;
resolving the array dependent items into script resources which refer to dynamic functions;
and embedding the script resources for referring to the dynamic functions into the head of the dynamic import template, and pre-loading.
In the embodiment of the present specification, a script resource and an import template are obtained by a template packager, and a Map (Map is a mapping from a key to a value) resource mapping list generated by an HTML template in a Dist directory is obtained by the template packager, where the Map resource mapping list includes an import template name, a page name and a dependent script resource name. Template packagers include Webpack, and the like. Webpack, a static module wrapper (module bundler) for modern JavaScript applications. When Webpack processes an application, it recursively builds a dependency graph that contains each module that the application needs, and then packages all of those modules into one or more bundles.
And loading the Map resource mapping list into a construction configuration item of the Webpack, searching a corresponding introduction template in the introduction template through the construction configuration item, analyzing the HTML template into character data, and matching the corresponding introduction template through the character data.
And judging whether the corresponding method for introducing the template contains the dynamic introduction template, and if so, replacing the dynamic introduction template into a plurality of groups of dependent items. And then the digital dependency is analyzed into script resources for quoting the dynamic function, and the script resources for quoting the dynamic function are embedded into the head of the dynamic introduction template to realize pre-loading and dynamic loading of the script.
In an embodiment of the present specification, the executing a templated task based on the hypertext markup language template, and dynamically loading a script further includes:
acquiring script resources and introducing a template;
generating a resource mapping list based on the hypertext markup language template;
loading the resource mapping list into a construction configuration item of a template packer;
searching a dynamic import template and a template dependent item from the import template based on the construction configuration item, and forming a number group item by the dynamic import template and the template dependent item;
parsing the array items into incoming script characters;
replacing the dynamic import template with an array of dependent terms;
resolving the array dependent items into script resources which refer to dynamic functions;
and embedding script resources for referencing dynamic functions into the head of the dynamic import template, and pre-loading the script resources.
In the embodiment of the present specification, a script resource and an import template are obtained by a template packager, and a Map (Map is a mapping from a key to a value) resource mapping list generated by an HTML template in a Dist directory is obtained by the template packager, where the Map resource mapping list includes an import template name, a page name and a dependent script resource name. Template packagers include Webpack, and the like. Webpack, a static module wrapper (module bundler) for modern JavaScript applications. When Webpack processes an application, it recursively builds a dependency graph that contains each module that the application needs, and then packages all of those modules into one or more bundles.
And loading the Map resource mapping list into a construction configuration item of the Webpack, searching a dynamic introduction template and a template dependent item in the introduction template through the construction configuration item, and forming a plurality of groups of items by the dynamic introduction template and the template dependent item.
And analyzing the array items into an introduction script character, and replacing the dynamic introduction template into an array dependent item. And analyzing the array dependence items into script resources for quoting the dynamic functions, and embedding the script resources for quoting the dynamic functions into the head of the dynamic introduction template to realize preloading and dynamic loading of scripts.
In an embodiment of this specification, the determining whether the corresponding method for importing the template includes a dynamic import template further includes:
and when the judgment result is that the product does not contain:
searching the number of the corresponding introduction templates based on the character data;
judging whether the number of the corresponding template introducing methods is single or not, and replacing the dynamic introducing template into a plurality of groups of dependent items when the judgment result is not yes;
resolving the array dependent items into script resources which refer to dynamic functions;
and embedding the script resources for referring to the dynamic functions into the head of the dynamic import template, and pre-loading.
In this embodiment of the present specification, when a corresponding template importing method does not include a dynamic template importing method, the number of the corresponding template importing methods is matched with the number of the corresponding template importing methods through character data, and whether the number of the corresponding template importing methods is single is determined, and when the determination result is not, the dynamic template importing method is replaced with the number of the groups of dependent items. And analyzing the array dependence items into script resources for quoting the dynamic functions, and embedding the script resources for quoting the dynamic functions into the head of the dynamic introduction template to realize preloading and dynamic loading of scripts.
In an embodiment of this specification, the determining whether the number of the corresponding template importing methods is single further includes:
when the judgment result is that:
replacing the corresponding import template with an array of dependencies;
confusing and compressing the corresponding introduced template to generate a new template;
compiling the new template into the compiled file directory.
In the embodiment of the present specification, it is determined whether the number of corresponding import template methods is single, and if so, the corresponding import template is replaced with the number of sets of dependent items. And obfuscating and compressing the corresponding introduced template to generate a new template, and compiling the new template to the Dist directory.
In this embodiment of the present specification, the resource mapping list includes an import template name, a page name, and a dependent script resource name.
In the embodiment of the specification, the Map resource mapping list comprises an introduction template name, a page name and a dependent script resource name.
In the embodiment of the present specification, a template library is obtained, the template library is compiled to obtain a hypertext markup language template, and a resource mapping list is generated through the hypertext markup language template, where the resource mapping list includes an introduction template name, a page name, and a dependent script resource name. And a template packer at the front end reads the resource mapping list, processes the resources and compiles codes to obtain script resources and a dynamic introduction template which quote the dynamic functions, and embeds the script resources which quote the dynamic functions into the head of the dynamic introduction template to realize preloading and dynamic loading of scripts.
Fig. 2 is a schematic structural diagram of an apparatus for dynamically loading a resource according to an embodiment of the present specification, where the apparatus may include:
the acquisition module is used for acquiring a template library;
the compiling module is used for compiling the template library into a compiling file directory, and the compiling file directory comprises a hypertext markup language template;
and the loading module is used for executing templating tasks based on the hypertext markup language template and dynamically loading scripts.
In an embodiment of the present specification, the compiling module includes:
the first compiling unit is used for compiling the template library into a hypertext markup language template;
and the second compiling unit is used for compiling the hypertext markup language template into a compiled file directory.
In an embodiment of the present specification, the loading module includes:
the acquisition unit is used for acquiring script resources and introducing templates;
the generating unit is used for generating a resource mapping list based on the hypertext markup language template;
the loading unit is used for loading the resource mapping list into a construction configuration item of the template packer;
the first searching unit is used for searching out a corresponding introduction template from the introduction templates based on the construction configuration items;
the first analysis unit is used for analyzing the hypertext markup language template into character data;
a second searching unit for searching the corresponding method of the import template based on the character data;
the judging unit is used for judging whether the corresponding method for introducing the template contains a dynamic introduction template or not, and when the judging result is that the method contains the dynamic introduction template, the dynamic introduction template is replaced by an array dependent item;
the second analysis unit is used for analyzing the array dependence items into script resources for quoting dynamic functions;
and the first embedding unit is used for embedding the script resource which refers to the dynamic function into the head of the dynamic import template and is preloaded.
In an embodiment of this specification, the loading module further includes:
the acquisition unit is used for acquiring script resources and introducing templates;
the generating unit is used for generating a resource mapping list based on the hypertext markup language template;
the loading unit is used for loading the resource mapping list into a construction configuration item of the template packer;
the third searching unit is used for searching out a dynamic import template and a template dependent item from the import template based on the construction configuration item, and forming the dynamic import template and the template dependent item into a plurality of groups of items;
a third parsing unit for parsing the array items into incoming script characters;
a replacement unit for replacing the dynamic import template with an array of dependent entries;
the fourth analysis unit is used for analyzing the array dependence items into script resources for quoting dynamic functions;
and the second embedding unit is used for embedding the script resource which refers to the dynamic function into the head of the dynamic import template and is preloaded.
In an embodiment of the present specification, the determining unit further includes:
and when the judgment result is that the product does not contain:
searching the number of the corresponding introduction templates based on the character data;
judging whether the number of the corresponding template introducing methods is single or not, and replacing the dynamic introducing template into a plurality of groups of dependent items when the judgment result is not yes;
resolving the array dependent items into script resources which refer to dynamic functions;
and embedding the script resources for referring to the dynamic functions into the head of the dynamic import template, and pre-loading.
In an embodiment of this specification, the determining whether the number of the corresponding template importing methods is single further includes:
when the judgment result is that:
replacing the corresponding import template with an array of dependencies;
confusing and compressing the corresponding introduced template to generate a new template;
compiling the new template into the compiled file directory.
In this embodiment of the present specification, the resource mapping list includes an import template name, a page name, and a dependent script resource name.
In the embodiment of the present specification, a template library is obtained, the template library is compiled to obtain a hypertext markup language template, and a resource mapping list is generated through the hypertext markup language template, where the resource mapping list includes an introduction template name, a page name, and a dependent script resource name. And a template packer at the front end reads the resource mapping list, processes the resources and compiles codes to obtain script resources and a dynamic introduction template which quote the dynamic functions, and embeds the script resources which quote the dynamic functions into the head of the dynamic introduction template to realize preloading and dynamic loading of scripts.
The functions of the apparatus in the embodiment of the present invention have been described in the above method embodiments, so that reference may be made to the related descriptions in the foregoing embodiments for details that are not described in the present embodiment, and further details are not described herein.
Based on the same inventive concept, the embodiment of the specification further provides the electronic equipment.
In the following, embodiments of the electronic device of the present invention are described, which may be regarded as specific physical implementations for the above-described embodiments of the method and apparatus of the present invention. Details described in the embodiments of the electronic device of the invention should be considered supplementary to the embodiments of the method or apparatus described above; for details which are not disclosed in embodiments of the electronic device of the invention, reference may be made to the above-described embodiments of the method or the apparatus.
Fig. 3 is a schematic structural diagram of an electronic device provided in an embodiment of the present disclosure. An electronic device 300 according to this embodiment of the invention is described below with reference to fig. 3. The electronic device 300 shown in fig. 3 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 3, electronic device 300 is embodied in the form of a general purpose computing device. The components of electronic device 300 may include, but are not limited to: at least one processing unit 310, at least one memory unit 320, a bus 330 connecting the various system components (including the memory unit 320 and the processing unit 310), a display unit 340, and the like.
Wherein the storage unit stores program code executable by the processing unit 310 to cause the processing unit 310 to perform the steps according to various exemplary embodiments of the present invention described in the above-mentioned processing method section of the present specification. For example, the processing unit 310 may perform the steps as shown in fig. 1.
The storage unit 320 may include readable media in the form of volatile storage units, such as a random access memory unit (RAM)3201 and/or a cache storage unit 3202, and may further include a read only memory unit (ROM) 3203.
The storage unit 320 may also include a program/utility 3204 having a set (at least one) of program modules 3205, such program modules 3205 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may comprise an implementation of a network environment.
Bus 330 may be one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
The electronic device 300 may also communicate with one or more external devices 400 (e.g., keyboard, pointing device, bluetooth device, etc.), with one or more devices that enable a user to interact with the electronic device 300, and/or with any devices (e.g., router, modem, etc.) that enable the electronic device 300 to communicate with one or more other computing devices. Such communication may occur via an input/output (I/O) interface 350. Also, the electronic device 300 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the internet) via the network adapter 360. Network adapter 360 may communicate with other modules of electronic device 300 via bus 330. It should be appreciated that although not shown in FIG. 3, other hardware and/or software modules may be used in conjunction with electronic device 300, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments of the present invention described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiment of the present invention can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (which can be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to make a computing device (which can be a personal computer, a server, or a network device, etc.) execute the above-mentioned method according to the present invention. The computer program, when executed by a data processing apparatus, enables the computer readable medium to implement the above-described method of the invention, namely: such as the method shown in fig. 1.
Fig. 4 is a schematic diagram of a computer-readable medium provided in an embodiment of the present specification.
A computer program implementing the method shown in fig. 1 may be stored on one or more computer readable media. The computer readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The computer readable storage medium may include a propagated data signal with readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A readable storage medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
In summary, the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that some or all of the functionality of some or all of the components in embodiments in accordance with the invention may be implemented in practice using a general purpose data processing device such as a microprocessor or a Digital Signal Processor (DSP). The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
While the foregoing embodiments have described the objects, aspects and advantages of the present invention in further detail, it should be understood that the present invention is not inherently related to any particular computer, virtual machine or electronic device, and various general-purpose machines may be used to implement the present invention. The invention is not to be considered as limited to the specific embodiments thereof, but is to be understood as being modified in all respects, all changes and equivalents that come within the spirit and scope of the invention.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A method for dynamically loading resources, comprising:
acquiring a template library;
compiling the template library into a compiled file directory, wherein the compiled file directory comprises hypertext markup language templates;
and executing a templated task based on the hypertext markup language template, and dynamically loading a script.
2. The method of dynamically loading resources of claim 1, wherein compiling the template library into a compiled file directory comprises:
compiling the template library into a hypertext markup language template;
and compiling the hypertext markup language template into a compiled file directory.
3. A method for dynamically loading resources according to claims 1-2, wherein the performing of templated tasks based on the hypertext markup language template dynamically loads scripts comprising:
acquiring script resources and introducing a template;
generating a resource mapping list based on the hypertext markup language template;
loading the resource mapping list into a construction configuration item of a template packer;
searching out a corresponding introduction template from the introduction templates based on the construction configuration items;
parsing the hypertext markup language template into character data;
searching the corresponding introduction template based on the character data;
judging whether the corresponding method for introducing the template contains a dynamic introduction template or not, and replacing the dynamic introduction template with an array of dependent items when the judgment result is that the corresponding method contains the dynamic introduction template;
resolving the array dependent items into script resources which refer to dynamic functions;
and embedding the script resources for referring to the dynamic functions into the head of the dynamic import template, and pre-loading.
4. A method for dynamically loading resources according to claims 1-3, wherein the performing a templated task based on the hypertext markup language template, dynamically loading a script, further comprises:
acquiring script resources and introducing a template;
generating a resource mapping list based on the hypertext markup language template;
loading the resource mapping list into a construction configuration item of a template packer;
searching a dynamic import template and a template dependent item from the import template based on the construction configuration item, and forming a number group item by the dynamic import template and the template dependent item;
parsing the array items into incoming script characters;
replacing the dynamic import template with an array of dependent terms;
resolving the array dependent items into script resources which refer to dynamic functions;
and embedding script resources for referencing dynamic functions into the head of the dynamic import template, and pre-loading the script resources.
5. The method for dynamically loading resources according to claims 1-4, wherein the determining whether the corresponding import template method contains a dynamic import template further comprises:
and when the judgment result is that the product does not contain:
searching the number of the corresponding introduction templates based on the character data;
judging whether the number of the corresponding template introducing methods is single or not, and replacing the dynamic introducing template into a plurality of groups of dependent items when the judgment result is not yes;
resolving the array dependent items into script resources which refer to dynamic functions;
and embedding the script resources for referring to the dynamic functions into the head of the dynamic import template, and pre-loading.
6. The method for dynamically loading resources according to claims 1-5, wherein the determining whether the number of the corresponding import template methods is single further comprises:
when the judgment result is that:
replacing the corresponding import template with an array of dependencies;
confusing and compressing the corresponding introduced template to generate a new template;
compiling the new template into the compiled file directory.
7. A method for dynamically loading resources as recited in claims 1-6, wherein the resource mapping list manifest includes import template names, page names, dependent script resource names.
8. An apparatus for dynamically loading resources, comprising:
the acquisition module is used for acquiring a template library;
the compiling module is used for compiling the template library into a compiling file directory, and the compiling file directory comprises a hypertext markup language template;
and the loading module is used for executing templating tasks based on the hypertext markup language template and dynamically loading scripts.
9. An electronic device, wherein the electronic device comprises:
a processor;
and a memory storing computer-executable instructions that, when executed, cause the processor to perform the method of any of claims 1-7.
10. A computer readable storage medium, wherein the computer readable storage medium stores one or more programs which, when executed by a processor, implement the method of any of claims 1-7.
CN202110804417.3A 2021-07-16 2021-07-16 Method and device for dynamically loading resources and electronic equipment Active CN113568678B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110804417.3A CN113568678B (en) 2021-07-16 2021-07-16 Method and device for dynamically loading resources and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110804417.3A CN113568678B (en) 2021-07-16 2021-07-16 Method and device for dynamically loading resources and electronic equipment

Publications (2)

Publication Number Publication Date
CN113568678A true CN113568678A (en) 2021-10-29
CN113568678B CN113568678B (en) 2023-12-12

Family

ID=78165062

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110804417.3A Active CN113568678B (en) 2021-07-16 2021-07-16 Method and device for dynamically loading resources and electronic equipment

Country Status (1)

Country Link
CN (1) CN113568678B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114510916A (en) * 2022-02-17 2022-05-17 平安科技(深圳)有限公司 Template loading method and device, computer equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130339841A1 (en) * 2012-06-14 2013-12-19 Open Text S.A. Systems and methods of a script generation engine
CN105653669A (en) * 2015-12-29 2016-06-08 网易(杭州)网络有限公司 HTML (Hypertext Marked Language) generating method and device
CN109189388A (en) * 2018-08-15 2019-01-11 深圳市轱辘汽车维修技术有限公司 Page configuration method, server and computer-readable medium
CN110990732A (en) * 2019-10-16 2020-04-10 平安国际智慧城市科技股份有限公司 Loading method, device and equipment based on webpage and storage medium
CN111241801A (en) * 2018-11-29 2020-06-05 北京京东尚科信息技术有限公司 File generation method, device, equipment and computer readable storage medium
CN111984887A (en) * 2019-05-23 2020-11-24 北京京东尚科信息技术有限公司 Webpage component library loading method and device, storage medium and electronic equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130339841A1 (en) * 2012-06-14 2013-12-19 Open Text S.A. Systems and methods of a script generation engine
CN105653669A (en) * 2015-12-29 2016-06-08 网易(杭州)网络有限公司 HTML (Hypertext Marked Language) generating method and device
CN109189388A (en) * 2018-08-15 2019-01-11 深圳市轱辘汽车维修技术有限公司 Page configuration method, server and computer-readable medium
CN111241801A (en) * 2018-11-29 2020-06-05 北京京东尚科信息技术有限公司 File generation method, device, equipment and computer readable storage medium
CN111984887A (en) * 2019-05-23 2020-11-24 北京京东尚科信息技术有限公司 Webpage component library loading method and device, storage medium and electronic equipment
CN110990732A (en) * 2019-10-16 2020-04-10 平安国际智慧城市科技股份有限公司 Loading method, device and equipment based on webpage and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114510916A (en) * 2022-02-17 2022-05-17 平安科技(深圳)有限公司 Template loading method and device, computer equipment and storage medium
CN114510916B (en) * 2022-02-17 2023-07-07 平安科技(深圳)有限公司 Template loading method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN113568678B (en) 2023-12-12

Similar Documents

Publication Publication Date Title
CN111680253B (en) Page application data packet generation method and device, computer equipment and storage medium
CN111240684B (en) Cutting method and device of JS codes, medium and electronic equipment
CN109766099B (en) Front-end source code compiling method and device, storage medium and computer equipment
US7131111B2 (en) Development of manifest for java embedded server bundle
JP5818695B2 (en) Code conversion method, program and system
JP5734311B2 (en) Efficient invariant syntactic representation with gradual change
US9940104B2 (en) Automatic source code generation
CN112379917B (en) Browser compatibility improving method, device, equipment and storage medium
CN104134039A (en) Virus checking and killing method, virus checking and killing client, virus checking and killing server and virus checking and killing system
CN116069325B (en) Front-end project construction method, device, equipment and computer readable storage medium
CN112328259A (en) Compiling time length processing method and device
CN115686606A (en) Method, device, system and medium for displaying item dependency tree
CN113568678B (en) Method and device for dynamically loading resources and electronic equipment
Michelon et al. Mining feature revisions in highly-configurable software systems
Wu et al. CoDocent: Support API usage with code example and API documentation
CN111782239B (en) Method, device and storage medium for software packaging and source code version information acquisition
CN116166907B (en) Method and device for developing Web application by using WebAsssembly and service page compiling technology
CN110489124B (en) Source code execution method, source code execution device, storage medium and computer equipment
Willighagen Citation. js: a format-independent, modular bibliography tool for the browser and command line
JP2879099B1 (en) Abstract syntax tree processing method, computer readable recording medium recording abstract syntax tree processing program, computer readable recording medium recording abstract syntax tree data, and abstract syntax tree processing device
CN108460276B (en) Processing method and device for SO file of dynamic link library of android installation package
Spinellis Tools and techniques for analyzing product and process data
CN111273940B (en) Method and device for uploading program file to code warehouse
CN113138767A (en) Code language conversion method, device, electronic equipment and storage medium
Balbaert Julia 1.0 Programming: Dynamic and high-performance programming to build fast scientific applications

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