Yepnope. js asynchronously loads resource files

Source: Internet
Author: User
Typical sample code: yepnope ({test: Modernizr. geolocation, yep: & amp; #39; normal. js & amp; #39;, nope: [& amp; #39; polyfill. js & amp; #39;, & amp; #39; wrapper. js & amp; #39;]}); When Modernizr. geoloca

Typical code example
Yepnope ({
Test: Modernizr. geolocation,
Yep: 'normal. js ',
Nope: ['polyfill. js', 'wrapper. js']
});
 
When Modernizr. geolocation is true, load the yep item, that is, "normal. js". Otherwise, load the nope item-you can load multiple files at the same time.
What is the difference between yepnope and the existing xxx script loader?
I personally think that the two main points are as follows:
Javascript and css can be processed simultaneously.
 
All yepnope Parameters
Yepnope ([{
Test:/* boolean (ish)-the expression you want to check for authenticity */,
Yep:/* array (of strings) | this parameter is loaded when string-test is set to true */,
Nope:/* array (of strings) | this attribute is loaded when string-test is set to false */,
Both:/* array (of strings) | string-loaded under any circumstances */,
Load:/* array (of strings) | string-load under any circumstances */,
Callback:/* function (testResult, key) | object {key: fn} execute the corresponding method when a url is loaded successfully */,
Complete:/* the function is loaded and executed */
},...]);
The parameters here can be array or object, which is useful when loading multiple resource files.
 
Yepnope loads jquery instance www.2cto.com
Yepnope ([{
Load: 'http:/clusters/ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js ',
Complete: function (){
If (! Window. jQuery ){
Yepnope ('local/jquery. min. js ');
}
}
},{
Load: 'jquery. plugin. js ',
Complete: function (){
JQuery (function (){
JQuery ('div '). plugin ();
});
}
}]);
This code asynchronously loads jquery and jquery. plugin. js, and even makes a backup for jquery loading failure.

 

From touch
 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.