I originally posted “Let’s just freeze Object.prototype" as a joke in Matrix but then I started thinking: could we?
This would not only partially address the issue with thenables, but also a host of other problems.
Before you say “no way”, bear with me:
“But that would break polyfillability!”
Except we have resolved to never add anything on Object.prototype ever again, so that’s not an issue.
“But that would break existing websites!”
Wouldn’t it be great if we had a use counter about what % of websites today depend on Object.prototype extensions? Oh wait, it seems like this already exists!
I had to do some digging to figure out what this use counter actually does, but based on these tests and this commit message, it appears that this is exactly what it’s measuring: how many non-built-in elements there are on Object.prototype! Actually, it’s measuring a larger number: whether members exist, not whether they are used.
If these stats are reliable, the % of page loads that actually do this is effectively 0%.
Actually freezing Object.prototype runs into the override problem (o.toString = … no longer works) but preventExtensions should work, I think? Could… this actually be a possibility?! ![]()