yepnope({
test : Modernizr.geolocation,
yep : 'normal.js',
nope : ['polyfill.js', 'wrapper.js']
});
yepnope([{
test : /* boolean(ish) 输入条件 */,
yep : /* array (of strings) | string - 条件为真时加载的资源 */,
nope : /* array (of strings) | string - 条件为假时加载的资源 */,
both : /* array (of strings) | string - 条件无论真假都加载 */,
load : /* array (of strings) | string - 条件无论真假都加载 */,
callback : /* function ( testResult, key ) | object { key : fn } 回调函数 */,
complete : /* function 加载完成后执行的函数 */
}, ... ]);
yepnope([
{
load: 'http://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();
});
}
}
]);
someLoader('http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js', function(){
if ( ! window.jQuery ) {
someLoader( 'local/jquery.min.js', 'jquery.plugin.js' );
/*注意这点和yepnope的区别,yepnope加载失败后仅需重新加载备用资源即可,不会影响依赖此资源的其他文件执行*/
} else {
someLoader( 'jquery.plugin.js' );
}
});
yepnope( '/url/to/your/script.js' );
yepnope( {
load : '/url/to/your/script.js'
} );
yepnope( {
test : window.JSON,
load : '/url/to/your/script.js',
callback : function ( url, result, key ) {
// whenever this runs, your script has just executed.
alert( 'script.js has loaded!' );
}
} );
yepnope( {
test : window.JSON,
nope : 'json2.js',
complete : function () {
var data = window.JSON.parse( '{ "json" : "string" }' );
}
} );
yepnope( {
test : Modernizr.geolocation,
yep : {
'rstyles' : 'regular-styles.css'
},
nope : {
'mstyles' : 'modified-styles.css',
'geopoly' : 'geolocation-polyfill.js'
},
callback : function ( url, result, key ) {
if ( key === 'geopoly' ) {
alert( 'This is the geolocation polyfill!' );
}
}
} );
yepnope( {
test : Modernizr.geolocation,
yep : {
'rstyles' : 'regular-styles.css'
},
nope : {
'mstyles' : 'modified-styles.css',
'geopoly' : 'geolocation-polyfill.js'
},
callback : {
'rstyles' : function ( url, result, key ) {
alert( 'This is the regular styles!' );
},
'mstyles' : function ( url, result, key ) {
alert( 'This is the modified styles!' );
},
'geopoly' : function ( url, result, key ) {
alert( 'This is the geolocation polyfill!' );
}
},
complete : function () {
alert( 'Everything has loaded in this test object!' );
}
} );
yepnope( 'css!mystyles.php?version=1532' );
yepnope( {
load : 'preload!jquery.1.5.0.js',
callback : function ( url, result, key ) {
window.jQuery; //undefined
yepnope(jquery.1.5.0.js);
window.jQuery; //object
}
} );
yepnope({
load: ['normal.js', 'ie6!ie7!ie-patch.js'] // ie6 or ie7 only (on patch)
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有