利用requestjs优化响应式移动端js加载

html:

<script data-main="main" src="require.js"></script>

main.js

require.config({
baseUrl: 'js',
shim: {
"zepto": {
exports: "$"
}
}
});
if(/AppleWebKit.*Mobile/i.test(navigator.userAgent)
|| /Android/i.test(navigator.userAgent)
|| /BlackBerry/i.test(navigator.userAgent)
|| /IEMobile/i.test(navigator.userAgent)
|| (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){
/*if(/iPad/i.test(navigator.userAgent)){alert("iPad平板");}else{alert("其他移动设备 www.111cn.net ");}*/
require(['zepto'],function($){
})
}else{
require(['jquery'],function($){
})
}

目录结构:
利用requestjs优化响应式移动端js加载

上一篇:自定义控件出现“loaded nib but the view outlet was not set”


下一篇:js获取url?后的参数