What I did at work today

May 01 2009

Case in Point Regarding Naming Anonymous Functions

Needed to optimize a new feature on an old YUI site:

After running the YUI source through a couple find-and-replaces, I got this:

And the problem was obviously a bad implementation and usage of getElementsByClassName.

The patterns:

Pattern Replacement
([A-Za-z0-9]+) = function $1 = function _$1
([A-Za-z0-9]+): function $1: function _$1

Edit: posted at the same time on Ajaxian.

Edit 2: Obvious those regular expressions could just be ([A-Za-z0-9]+)(\s*[:=]) function to be replaced with $1$2 function _$1

Page 1 of 1