论坛首页 Web前端技术论坛

JavaScript中的对象动态加载技术

浏览 7080 次
精华帖 (1) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2010-05-07  

js的动态加载,要处理异步不难。难的是如何并行加载,并且保持顺序,还能不阻塞其他资源的下载。最好还能实现模块化的加载。

 

贴点我自己的框架的代码,和yui的有点像。

EAS_JS.Script
	.build({
		name : 'jquery',
		url : 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'
	})
	.build({
		name : 'local',
		def : function () {
			$('#test').html($('#test').html() + 'local > ');
		}
	})
	.build({
		name : 'test',
		url : 'http://www.w2blog.net/Templates/script/opFeedback.js'
	})
	.build({
		name : 'index',
		def : function () {
			$('#test').html($('#test').html() + 'index > ');
		},
		requires : ['jquery', 'local', 'test']
	});

EAS_JS.Script.run({
	name : 'index'
});

 

0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics