A kind of dynamic loading method for being used for micro- application data and the page
Technical field
Believe the present invention relates to power network in mobile internet environment web Dynamic loading techniques, specifically a kind of electric power that is used for
Cease the dynamic loading method of micro- application data and the page.
Background technology
Bootstrap Mobile solution Development Frameworks, Bootstrap are based on Less, abundant Mixin, are had abundant
Delete case system, lattices are applied to the equipment for being more than or equal to separation size with screen width, and are set for the small screen
Standby covering lattices.Therefore, lattices are applied to the equipment for being more than or equal to separation size with screen width on element,
And for small screen device covering lattices.Therefore, applied on element, also influence giant-screen equipment.
The advantages of framework is that can have compatibility height, response type cloth with fast adaptation PC ends, mobile terminal showing interface
The features such as office, grid type design, but the deficiency of bootstrap frameworks is can not to meet the need of Mobile solution development behavior loading
Ask.
Amaze UI Mobile solution Development Frameworks, Amaze UI are opened by domestic first of Beijing Mei Tongyundong companies exploitation
Source is across screen, lightweight, high-performance front end frame.The framework is preferably theory with movement, and large-size screen monitors are progressively expanded to from smaller screen, can
It is adapted to most equipment screen.By realizing that animation interacts with reference to CSS3 technologies so that show effect more smoothly, efficiently, Web
Using loading velocity faster.The framework includes abundant CSS, Js, Web component simultaneously, can go out experience remarkably with rapid build
Across screen interface.Inside so more advantages, Amaze UI do not possess the demand of Dynamic loading technique yet.
The content of the invention
It is an object of the invention to provide a kind of dynamic loading method for micro- application data and the page, this method according to according to
The recurrence for the relation of relying performs document creation script bank, reduces network request, also improves Consumer's Experience.
The purpose of the present invention is achieved through the following technical solutions:
A kind of dynamic loading method for being used for micro- application data and the page, it is characterised in that:This method passes through acquisition module code
Content in method, go to create script therein to realize dynamic load;It is segmented and is loaded by call back function, according to dependence nearby
Principle recurrence perform script, from top to bottom load document successively;By the file acquisition call back function of dynamic load, logic is carried out
Judge to realize segmentation loading, reduce network request, improve Consumer's Experience.
It is specific as follows:
1)Path configures
paths: {
"basepath":basepath
}
Basepath is then the current path of definition
2)Preload item
preload:['basepath/css/main.css',
'basepath/js/modules/jquery-1.9.1.min',
'basepath/js/modules/public'
]
3)Basic path
base: "" + basepath + "/js/modules/"
4)Alias configures
alias: {
"dialog": "dialog/dialog"
}
5)Page request
require(“dialog”);// dynamic load alias pattern and js
require(“index”);// dynamic load logic js
require(“index.css”);// dynamic load pattern css.
Dynamic load information, load what is interacted with service end using the preload in configuration pre-loaded when
Js and css.When js and css is loaded needed for some page, usable require directly relies on loading, so as to accomplish
The few code of write pole, come pattern and logic needed for dynamic load.
The present invention both reduces network request, also improves Consumer's Experience.
Embodiment
A kind of dynamic loading method for micro- application data and the page, by the content in acquisition module code method,
Go to create script therein to realize dynamic load;It is segmented and is loaded by call back function, is performed according to nearby principle recurrence is relied on
Script, from top to bottom load document successively;By the file acquisition call back function of dynamic load, carry out logic judgment and realize segmentation
Loading.
It is specific as follows:
1. path configures
paths: {
"basepath":basepath
}
Basepath is then the current path of definition
2. preload item
preload:['basepath/css/main.css',
'basepath/js/modules/jquery-1.9.1.min',
'basepath/js/modules/public'
]
3. basic path
base: "" + basepath + "/js/modules/"
4. alias configures
alias: {
"dialog": "dialog/dialog"
}
5. page request
require(“dialog”);// dynamic load alias pattern and js
require(“index”);// dynamic load logic js
require(“index.css”);// dynamic load pattern css.
The present invention is directed to mobile terminal internal memory, flow, limited battery resources under mobile internet environment, is added by using dynamic
Load technology, program file is dispersed as multiple small documents, with delay loading technology, realizes that on-demand loading lifts Consumer's Experience, drop
The resource utilization of low mobile terminal.In business and pattern, front end developer only needs to quote what is needed in code block header
Plugin library and model code.Logically, the interface that developer need to only call rear end to provide is read out and shown.It is right
Have different deployment requests on a different server in disparity items, such dynamic load for a difficult point, so
In the reference of module, it need to accomplish that the unification in path is consistent with rule.