|
|
|
|
|
by slexaxton
5164 days ago
|
|
Doesn't `with` have significant runtime costs? I didn't think people didn't like that one because it was a 'bad pattern' - I thought it was because it was really slow. EDIT: I went ahead and JSPerf'd it, and it is 13x slower to run the example in the article. http://jsperf.com/with-perf A lot of times this doesn't matter, but it's not nothing. Edit 2: Also people avoid using `with` so their minification tools have a better chance. Another thing that can be overcome, but just pointing out that it's not religious dogma that makes people avoid `with`. |
|
I think that once you start optimizing performance problems you need to 1) measure things anyway, and 2) fix on a case-by-case basis. (Don't optimize prematurely, etc.)