I was looking for a quick way to profile some code in IE. I didn’t want to grab Tito (commercial) or JsLex (browser independent, sweet, but a bit of a hog). So I went hunting for a simple little AOP library for Javascript and came across Ajaxpect. In 58 lines of Javascript, it gives you the ability to add before, after and around advice. From the included example:
// Example business logic var thing = { makeGreeting: function(text) { return 'Hello ' + text + '!'; } }alert(thing.makeGreeting('world')); // Hello world!
// Advice definitions function aopizeAdvice(args) { args[0] = 'AOP ' + args[0]; return args; } function shoutAdvice(result) { return result.toUpperCase(); } function ciaoAdvice() { return 'Bye-bye!'; }
// Adding advices Ajaxpect.addBefore(thing, 'makeGreeting', aopizeAdvice); alert(thing.makeGreeting('world')); // Hello AOP world! Ajaxpect.addAfter(thing, /make*/, shoutAdvice); alert(thing.makeGreeting('world')); // HELLO AOP WORLD! var filter = function(name) { return name.indexOf('Greet') != -1 } Ajaxpect.addAround(thing, filter, ciaoAdvice); alert(thing.makeGreeting('world')); // Bye-bye!

You might find my lib [1] interesting. After configuration, where you in particular have to activate Profiler interceptor [2], it only takes
CERNY.intercept(YourObj);
to have the profiling information printed to the console you configured. Since YourObj does not have a logger the statements will be logged under the category “NONE”, which is set to TRACE by default. I did a fair amount of profiling code under IE and it worked out pretty well!
[1] http://www.cerny-online.com/cerny.js/
[2] http://www.cerny-online.com/cerny.js/documentation/guides/interception