javascriptjqueryrequirejsjquery-eventsdomready

requirejs with jQuery .domready() is not fired correctly


When you load jquery 1.8.2 with requirejs 2.1.1 - $(document).ready() and $(window).load() events starts to behave really weird.

Sometimes only one of them are fired sometimes both but in all cases they are fired after all content, images etc are loaded -.load() event.

Switching to jQuery 1.7.2 makes .load() work properly though .ready() acts as .load() and is never fired on real DOM ready event. Am I doing something wrong here or not only me having these issues?

Example (open console and refresh):

http://jsbin.com/epujom/5

Source:

http://jsbin.com/epujom/5/edit

EDIT: I have updated test case. Now it is clearly seen that jQuery.isReady = false even when DOM is ready


Solution

  • The only way i can achieve a result i wanted is to load in the head section domready plugin like

    https://github.com/freelancephp/DOMReady

    or

    https://github.com/requirejs/domReady

    domready plugin or attaching events should always be ran before actual browser domready event occurs otherwise all of them are waiting for all images to be loaded and that is not what you want.