Created
March 2, 2012 12:52
-
-
Save colingourlay/1958226 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (w) { | |
// Define two queues for handlers | |
w.readyQ = []; | |
w.bindReadyQ = []; | |
// Define the fake jQuery function to capture handlers | |
w.$ = w.jQuery = function (handler) { | |
// Push a handler into the correct queue | |
function pushToQ(x, y) { | |
if (x == "ready") { | |
w.bindReadyQ.push(y); | |
} else { | |
w.readyQ.push(x); | |
} | |
} | |
if (handler === document || handler === undefined) { | |
// Queue $(document).ready(handler), $().ready(handler) | |
// and $(document).bind("ready", handler) by returning | |
// an object with alias methods for pushToQ | |
return { | |
ready: pushToQ, | |
bind: pushToQ | |
}; | |
} else { | |
// Queue $(handler) | |
pushToQ(handler); | |
} | |
} | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I read your article : https://writing.colin-gourlay.com/safely-using-ready-before-including-jquery/
and implemented this in our site. Its working in chrome and firefox, IE but its not working in safari.
any clue how I can make this work on safari as well?
thanks,