4 ms·
Declaring functions like 'returnTrue' was a way to prevent memory leak in old IE (~IE6/IE7) (instead of creating a new inline function each time a method is cal
by jakub_g 6y ago
Declaring functions like 'returnTrue' was a way to prevent memory leak in old IE (~IE6/IE7) (instead of creating a new inline function each time a method is called). It was especially important when a function is a closure and has a ton of variables visible in outer scope (in particular, refs to DOM nodes) and is called many times. Otherwise you end up with circular references between the objects and nothing can be garbage collected (GC implementation in old IE was very bad).
- petepete 6y agoI remember replacing some functions like this in a codebase I used to work on about twenty years ago. The senior dev at the time had to add them back a day or two later whe the site totally broke for IE users after a couple of minutes. Fun times.
- bryanrasmussen 6y agoI hope he added in a comment /* don't remove or refactor this, IE6 will break */
- uncledave 6y agoOh god there’s so much of that I’ve written over the years. It’s still in there now. Fortunately minification eats my shame publicly. Think the worst one was we had some code that would add a pad in somewhere after the page was rendered that would cause IE6 to redraw the page correctly.