延迟加载和依赖项解析 [英] Lazy loading and dependency resolution

查看:105
本文介绍了延迟加载和依赖项解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前一段时间,我正在读一篇关于他的图书馆如何做的文章(一个人建造的图书馆)

some time ago, I was reading an article(a library built by some guy) about how his library can do


  1. 延迟加载JS

  2. 解决JS
    之间的依赖关系(通常在尝试将
    包含来自另一个js时遇到)

  3. 仅包含文件一次。认为
    多次指定,无论
    如何调用它们(
    直接指定为文件或
    指定它作为
    依赖项之一)

我忘了给它添加书签,这是多么的错误。有人可以指出我能做到的事情。我知道DOJO和YUI库有这样的东西,但我正在寻找一些可以用于jQuery的东西

I forgot to bookmark it, what a mistake. Can some one point me to something which can do the above. I know DOJO and YUI library have something like this, but I am looking for something which I can use with jQuery

我可能还在寻找另外一个功能。

I am probably looking for one more feature as well.


  • 我的网站有asp.net用户控件
    (可重复使用的服务器端代码片段)
    有一些JS。他们中的一些人立即获得
    ,当页面为
    loading时,会给用户带来不良的
    体验。 Yahoo性能
    指南
    指定JS应该
    是在页面的底部,但
    这在我的情况下是不可能的
    这将要求我将
    JS和相应的服务器端
    控件分成不同的文件和
    维护将很困难。我
    绝对可以在我的用户控件
    JS中放置一个jQuery
    document.ready()以确保它在DOM加载后仅触发
    ,但我是
    寻找更简单的解决方案。

  • My site has asp.net user controls (reusable server side code snippets) which have some JS. Some of them get fired right away, when the page is loading which gives a bad user experience. Yahoo performance guidelines specify that JS should be at the bottom of the page, but this is not possible in my case as this would require me to separate the JS and the corresponding server side control into different files and maintenance would be difficult. I definitely can put a jQuery document.ready() in my user control JS to make sure that it fires only after the DOM has loaded, but I am looking for a simpler solution.

无论如何我可以说开始执行任何 JS只有在DOM以全局方式加载document.ready之后才能加载每个用户控件?

Is there anyway that I could say "begin executing any JS only after DOM has loaded" in a global way than just writing "document.ready" within every user control ?

推荐答案

好的我我发现链接

http://ajaxian.com/archives/usingjs-manage-javascript-dependencies
http://www.jondavis.net/techblog/post/2008/04/Javascript-Introducing-Using-%28js%29.aspx

我还找到了一个,对于对延迟加载/动态js depe感兴趣的人ndency resolution

I also found one more, for folks who are interested in lazy loading/dynamic js dependency resolution

http://jsload.net/

这篇关于延迟加载和依赖项解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆