-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Set instead of Array #8
Conversation
What is browser support for |
@developit, unfortunately, all the trusted tables (kangax?) show info starting from IE11. Can't we drop IE9/IE10 support by default and recommend using polyfill if needed? |
Personally everything I do still needs to support IE9+, since that's what I support both for Preact-related things and at work. Might need to ponder this for a bit. |
@developit could output multiple builds one for modern, old for old, make one the default |
@hzoo that's good idea, btw. Worth nothing. |
That's a really good idea. Same outward interface, just vary the internals to take advantage of |
@hzoo what about the con outlined in the first post? Would the two builds behave differently? I don't think it's worth it, generally event listeners don't care for duplicate handlers and this would break that expectation. |
This might be interesting when paired with FWIW, I've changed the build around a bunch so that the gzipped size is actually tracking the universal bundle output, not just the commonjs output. This made it a lot harder to stay below 200 bytes, but I managed to do it. The update is here: 3a675c7 --edit-- @alexeyraspopov I don't think the |
Don't confuse |
I already tried that PR and it don't have impact. It is still 181b. |
@tunnckoCore - tried the |
@developit even if they are doing it (which isn't necessarily true), babel doesn't automatically polyfill Set |
I know, just |
@developit, it does some unexpected thing :( |
@bfred-it what do you mean by automatically polyfill Set? technically everything is opt-in (and that's the repl which has specific presets?) |
@alexeyraspopov that's a fairly odd thing for buble to do, I guess it's just not accounted for at all. |
^ It does the same thing as Babel in loose mode since it assumes it's an array |
Just read its docs.
Nothing surprising for me. |
And that is the same as Babel - either you use babel-polyfill, your own polyfill, or transform-runtime https://babeljs.io/#polyfill |
@hzoo that's the issue: configuration. By default browserify doesn't run on node_modules at all so even if it In short, this is not automatic and it's essentially the same as raising the support to IE11, since it requires the user to supply polyfills. |
Yeah this is what w3ctag/polyfills#6 is all about. It's not the same if you provide multiple builds like I mentioned. If someone really wants the savings they can use the other alternative build with Set, etc |
Most easier thing is to provide two versions and I dont seeing the problem of that. One using Set, one that uses array. Based on one codebase. It can be done with with Rollup (the replace plugin) and most things from the npm scripts line would go into two separate rollup config files. |
Any chance we could compare performance between Array and Set for this use-case? I don't mind setting something up on ESBench but I'll likely not get to it for a few days |
I'm not well versed in putting together these kinds of benchmarks, but I took a stab at it: https://esbench.com/bench/587ed73899634800a0347623 . I'm happy to fix/change whatever's necessary. The following results were gathered by running my test with Babel transpilation disabled. Chrome 55 (Current)
Chrome 57 (Canary)
Firefox 50.1.0 (current)
Firefox 52.0a2 (Dev Edition)
Safari 10.0.2
Safari Tech Preview Release 21
|
wow you are amazing @SVincent 🌟🙇 I can't say I'm entirely surprised Set performs so poorly compared to Array. One of the key advantages of |
While Set vastly underperforms today, I very much hope JS engines will optimize it to be near (or better than) Array's performance. I always assumed that Set and Map would allow for a new class of optimizations not possible with Array and Object. We can already see evidence of perf improvements in the Chrome 55 vs. 57 numbers. So there's hope, I think. Of course we also live in the here and now. Given the wild variance in Set performance it's probably best to stick with Array until all evergreens are within (say) at least 50% of Array's perf. |
Agreed with both opinions there. Plus we have a PR sitting here for when Set gets hyper-optimized and we need to switch for perf reasons 👍 |
Pros:
*
and in other types are called only onceCons: