Вопрос

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