-
I've noticed the interesting pattern in source modules where globals and instance methods are copied into variables in each polyfill module. I'm guessing this is the relevant style rule
I did some benchmarking, and at least on modern v8 it doesn't significantly alter performance (spidermonkey gets massive slowdowns, though). Does this have a larger impact on some older javascript engines? Or is it a defensive programming practice, to avoid interacting with other polyfills or user-code patching global class methods, and not primarily a performance concern? Or is there some other benefit that I don't know about at all, maybe static analysis? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You listed the main reasons, there are many. Performance (in some cases, as you noticed, sometimes it's actually bad for performance), better compression, but there are minor things. The main thing is that monkey patching of globals by third-party code / user / malefactor can break the library code / make internal logic observable or change it. Also, |
Beta Was this translation helpful? Give feedback.
You listed the main reasons, there are many. Performance (in some cases, as you noticed, sometimes it's actually bad for performance), better compression, but there are minor things. The main thing is that monkey patching of globals by third-party code / user / malefactor can break the library code / make internal logic observable or change it. Also,
core-js
by itself patches many things, and avoiding of cash here could cause many different problems like circular calling.