Skip to content

Instantly share code, notes, and snippets.

@ahsquared
ahsquared / defer_doc_ready_jquery.html
Created April 26, 2012 05:51
Defer a document ready call
<!DOCTYPE html>
<html lang="en">
<head>
<!-- this collects the jquery document ready calls
// used with gratitude from: http://blog.colin-gourlay.com/blog/2012/02/safely-using-ready-before-including-jquery/ -->
<script>(function (w, d, u) { w.readyQ = []; w.bindReadyQ = []; function p(x, y) { if (x == "ready") { w.bindReadyQ.push(y); } else { w.readyQ.push(x); } }; var a = { ready: p, bind: p }; w.$ = w.jQuery = function (f) { if (f === d || f === u) { return a } else { p(f) } } })(window, document)</script>
</head>
<body>
<!-- this is on the page and you want to defer it -->
<script type="text/javascript">