Skip to content

Instantly share code, notes, and snippets.

@pkriete
Forked from paulirish/$.logCallsTo.js
Created January 24, 2010 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkriete/285207 to your computer and use it in GitHub Desktop.
Save pkriete/285207 to your computer and use it in GitHub Desktop.
// sorta like manual profiling.
// peek into your jquery method calls to see why they are being called so much
// usage:
// $.logCallsTo('append');
// $.logCallsTo('curCSS',true);
// output:
// http://gyazo.com/40cec25d875a7a767e95fd7a2f451b32.png
$.logCallsTo = function(method,isOn$){
var old = isOn$ ? $[method] : $.fn[method],
that = this;
(isOn$ ? $ : $.fn)[method] = function(){
window.console && console.log.apply(console,[this,method,arguments]);
return old.apply(this,arguments);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment