`Map` polyfill (`get(key)`) is very slow
See original GitHub issueWe recently starting using polyfill-library@3.34.0
to polyfill ES6 for (only) IE11 in Tableau. This caused a severe performance regression in our rendering code, which was traced to the Map
polyfill. Removing Map
and Set
from our config resolved the issue – luckily our code only currently needs the native partial support for Map
in IE11. (I don’t know if removing Set
was also necessary, but since IE11 has partial support for both, I decided to err on the side of removing both.)
Unfortunately I have not investigated deeply enough to suggest a fix, but our profiling session indicated CreateMethodProperty(Map.prototype...) (23.1.3.6 Map.prototype.get (key))
was the culprit.
Here is our config, for reference:
const ie11_es6_opts = {
uaString: 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko',
minify: false,
excludes: [
'Map',
'Set',
],
features: {
'es6': { flags: ['gated'] }
}
};
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Why is JavaScript map() polyfill so slow
The property with the key '2' is no longer defined. For Arrays that means there is an empty slot. The specification also allows...
Read more >How do the ES6 Map shims work - Stack Overflow
There are two ways that come to mind. First, obviously, you can have an array of keys, and search it linearly: Map1 =...
Read more >Why is JavaScript map() polyfill so slow – Valuable Tech Notes
According to a JSPerf snippet (and some others), default JavaScript map() implementation is 21% slower than using a basic for . enter image...
Read more >Array.prototype.flatMap() - JavaScript - MDN Web Docs
The flatMap() method returns a new array formed by applying a given callback function to each element of the array, and then flattening...
Read more >Maps and Sets, goodbye polyfill ?! - ES Discuss
What do engines do when they face an object-as-map (random and potentially numerous keys)? Do they try to find a shape/hidden class and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@zloirock Good point! I missed that part when reading the spec, thanks for pointing it out.
@neenhouse, feel free to implement a more optimised implementation 😃
@craigkovatch Yes please, if you could link it to this issue that would be great