锁定老帖子 主题:JavaScript中的对象动态加载技术
精华帖 (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' });
|
|
返回顶楼 | |