pace.js: "start" event not triggered?

matt picture matt · Dec 15, 2014 · Viewed 7.6k times · Source

I can't seem to find a solution to this problem I posted in the comments of this question … I'm using the pace.js plugin and I would love to load/show parts of my page immediately without having to wait for the preloader to load all content.

I thought of doing this by simply calling the start event and show the selector immediately.

However I can't seem to find the cause why my done event is fired, but start is not. I also tried with hide which is also fired, but stop or restart is not.

$(window).load(function(){

    Pace.on('start', function() { 
        alert('start') // not fired
    });

    Pace.on('done', function() {
        alert('done') // fired!
    });

});

Any ideas?

Answer

user405398 picture user405398 · Dec 17, 2014

Call Pace.start(), right after event bindings. You then will be able to get the start event.