jQuery ready/load

by Jason Aden

HTML

<iframe src="http://jquery.com"></iframe>

CSS

iframe {
    width: 100%;
    height: 400px;
}

JavaScript

// Option one
$(document).ready(function(){
   
    console.log("Document loaded");
    
});

// Option two
$(function () {
    console.log(Date.now(), "document loaded");
});

// Can do this on window, but this event
// fires once EVERYTHING is loaded
// including images... too slow for us
$(window).load(function () {
    console.log(Date.now(), "window loaded");
});

// And another shortcut to document.ready
$().ready(function() {
    console.log("Ready shortcut");
});