Roy Tang

Programmer, engineer, scientist, critic, gamer, dreamer, and kid-at-heart.

Blog Notes Photos Links Archives About

I’m trying to trace a slowdown on load of a web page in our application and there’s a ton of JavaScript to go through so I’d rather not process them individually.

I’m trying to see if there’s a way to list out all the event handlers added to $(document).ready() so that I would just look through those handlers to see what might be causing the problem.

Is there a way to do this?

Comments

I tried the solution here: http://stackoverflow.com/questions/4138543/list-all-bindings-of-an-elment-with-jquery but it didnt include the ready handlers apparently

I was able to do this by overriding jquery’s ready function itself so that I could store references to the handlers, i.e.

var readyList = [];
var origReady = jQuery.fn.ready;
jQuery.fn.ready = function() {
  if ((arguments.length) && (arguments.length > 0) 
    && (typeof arguments[0] === 'function')) {
      readyList.push(arguments[0]);
  }
  origReady.apply(this, arguments);
}