I'm trying to decorate jQuery document.ready function
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(function() {
console.log("ready2");
});
</script>
<script type="text/javascript">
$.fn.ready = (function(fn) {
return function() {
console.log("ready1");
return fn.apply(this, arguments);
}
})($.fn.ready);
</script>
</head>
<body>
<img src="http://deelay.me/1000?http://my-site.com/image.gif" />
</body>
</html>
What I'm expecting to see - is "ready1" and "ready2" in browser console, however there is only "ready2". What I'm missing?
FiddleJS: http://jsfiddle.net/GXCnu/
UPDATE #1: Well actually its clear why its not working - its because I'm calling ready() first.... Then another question - how to call custom function just before $.ready() will be triggered?