質問

Let's say you're loading a bunch of super heavy images with a js preloader (Preload.JS) and in the callback you have your $(document).ready function.

Example code:

var queue = new createjs.LoadQueue();

queue.loadManifest([
    "img/1.jpg",
    "img/2.jpg",
    "img/3.png"
]);

queue.on("complete", preloadComplete, this);

function preloadComplete() {

    $(document).ready(function() {
        //jquery stuff
    });
}

Is it possible that the preloading could take so long that the ready function gets missed?

役に立ちましたか?

解決

The ready function can't be "missed". Even if the document is already ready, the function within it will run.

http://api.jquery.com/ready

If .ready() is called after the DOM has been initialized, the new handler passed in will be executed immediately.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top