10 ms·
Twitter web app now runs ES6+, reducing polyfill bundle size by 83%
- alexcroox 6y agoJoys of being able to drop IE11
- nikivi 6y agoHope it happens for all sites going forward. Alongside everyone supporting prefers-color-scheme for dark modes. https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pref...
- wongmjane 6y agoBy gzipped size I’m referring to the polyfill bundle itself update: thanks for disambiguating the title, OP!
- Ajedi32 6y agoI think that was actually pretty clear from your tweet; it's just the title of this post which is misleading. Edit: For context, previous title was "Twitter web app gzip size dropped from 16.6 KB to 2.7 KB by removing polyfills"
- tosh 6y agoupdated title to clarify, ty!
- vijaybritto 6y agoDo you have any information on how they achieved this?
- wongmjane 6y agoThey now have two production build variations (I’m guessing two Webpack config): modern: ES6+, less polyfill legacy: ES5, more polyfill The appropriate variation is served by detecting browser’s version from the User-Agent string
- axlee 6y agoNote: since v8.0, Angular comes with built-in differential loading and will do all the heavy lifting to achieve exactly that. https://angular.io/guide/deployment#differential-loading https://angular.io/guide/deployment#differential-loading
- wongmjane 6y agoupdate: a Twitter engineer explained how they implemented it in greater detail https://twitter.com/charliecroom/status/1291478104016289799 https://twitter.com/charliecroom/status/1291478104016289799
- ericlewis 6y agoJane!
- lathiat 6y ago“A polyfill is code that implements a feature on web browsers that do not support the feature. Most often, it refers to a JavaScript library that implements an HTML5 web standard, either an established standard on older browsers, or a proposed standard on existing browsers.”
- username3 6y ago“twitter.com no longer supports Internet Explorer 11” https://twitter.com/i/release_notes https://twitter.com/i/release_notes
- pedrocx486 6y agoAnd this is good. This browser needs to die already. I'm glad the company I work at also dropped IE in new projects and have plans to upgrade older projects too.
- kaycebasques 6y agoQuick check-in: who here is still supporting IE? Please provide as much detail about your website (industry, audience, usage) as possible.
- wilsonrocks 6y agoWe support IE11. Mainly high end websites and web apps about employee benefits. I think one of the main drivers of IE support is clients who will test in IE because it's their default browser or only allowed browser at work.
- nicoburns 6y agoWe are. b2b healthcare industry. About half our clients have Chrome available. The rest are still on IE11.
- etaioinshrdlu 6y agoIs it corporate IE policies mandating the use of IE11? I find this so fascinating.
- sushshshsh 6y agoInfosys still requires all employees to access internal applications (time sheet, banking) via internet explorer only. However the apps developed for clients are for Chrome
- wilsonrocks 6y agoI'd love to see some stats on page load times etc. There's a lot of repetitive debate on HN about JS web apps slowing things down and I'd like to know if the effects would be as bad if you could use the latest browser tools unpolyfilled.
- asadkn 6y agoIt used to be terrible due to long parsing time but over the past 5 years or so, things have really improved, even more so in v8 recently [1]. Nowadays it's safe to just focus on the overall package size. And once it goes over a certain size budget (that's over 150KB gzipped as my personal preference) split it up and ideally use the PRPL pattern. [1]: https://v8.dev/blog/cost-of-javascript-2019 https://v8.dev/blog/cost-of-javascript-2019
- mrsharpoblunto 6y agoI added support for ES2017 bundles for compatible browsers for Instagram.com a couple of years ago - we saw a 5.7% reduction in the size of our core consumer JavaScript bundles when we removed all ES2017 transpiling plugins from our build. In testing we found that the end-to-end load times for the feed page improved by 3% for users who were served the ES2017 bundle compared with those who were not (more info here https://instagram-engineering.com/making-instagram-com-faster-code-size-and-execution-optimizations-part-4-57668be796a8 https://instagram-engineering.com/making-instagram-com-faste...)
- mattmanser 6y ago3% is in the margin of error, surely, so basically no gain? Just a waste of dev time? Feels like you should make that the start of the blog post and cut it down massively, so people know it's not worth bothering with?
- azemetre 6y agoI'm actually kinda curious about this in regards to browser finger printing. This isn't like statistics in a political poll where there is an expected margin or error, when it comes to logging sites you absolutely know everything about your users in regards to browser, operating system, and even the hardware (sometimes). 3% of a million is 30,000, 3% of 500,000,000 is 1,5000,000. An absolutely real chunk of users that can produce real value (for Instagram, ad dollars). Why would there be a margin error at all? How would it be introduce? A large portion of crawlers masking themselves? I mean it's possible, but I do not know if that's enough to throw off proper logging.
- dmitriid 6y agoGlad to see at least something happening on the web side of Twitter. Because frankly their website is a hot mess of invalid, incorrect or messed up UX states and interactions. Hopefully that will be the next step after reducing the bundle size.
- stabbles 6y agoIs there actually a completely static version of Twitter as well? A 0.0 KB JS version?
- progval 6y agoTwitter works with JS disabled, but there's a nag screen on every page load. Alternatively, for reading only, there is https://nitter.net/ https://nitter.net/
- passive 6y agoNow when are they going to stop it auto-refreshing on desktop Chrome, making it functionally useless?
- m3kw9 6y agoThese size decreases would practically matter in the 14.4k baud modem days.
- wonderlg 6y agoI’m sure you love the modern web and its 2MB average page load, but most people don’t. This is code, so after it’s downloaded it needs to be parsed and executed… needlessly. What are you complaining about exactly?
- nikitaga 6y ago> (gzipped size went from 16.6 KB down to 2.7 KB!!) A couple orders of magnitude are missing from these sizes if my browser dev console is any indication. What are they even talking about.
- chrismorgan 6y agoThe polyfills, not their own code. Effectively all they did was update their browser support baseline, dropping support for very old browsers, with the result that about 14KB of code that made it work on those old browsers can now disappear, because more recent browsers don’t need it.
- coding123 6y agoWait, all of twitter (except for the content) is now about 3k?
- azangru 6y ago
- apazzolini 6y agoHas anyone else noticed that as of a few days ago, middle-clicking a tweet that's embedded in another tweet (like a retweet with comment) causes the new tab to steal focus? It's worse than scroll jacking IMO.
- dzhiurgis 6y agoAnyone elses scrolling still messed up with ad blocker? And hope this change makes it easier to block trends from explore tab. I love topics, but I don’t wanna see all the celebrity and politics crap every day...
- faangFar 6y agoTwitter is unusable if you want to avoid Politics. I unfriended almost everyone but all it takes is a single Like from anyone and it's Politics galore.
- augustus0 6y agoI really wish they'd add "harmony mode" or something that would get you away from the shrill toxicity of standard Twitter. People can't help themselves but click "like" on the most extreme statements possible, so users are incentivized to make the most extreme statements to maximize likes. The only success I've had is by starting a private list of knowingly healthy users that's aggressively curated to make it stay that way, and never looking at the home timeline.
- dzhiurgis 6y agoThey need synonyms for mute words
- wackget 6y agoTwitter is garbage as far as I'm concerned. I use Firefox with uBlock (standard lists) and uMatrix (all Twitter-related requests permitted) and it's still buggy as hell. If I try to paste anything into the "compose tweet" dialog it just completely crashes with a very helpful "something went wrong" message. If I try to cut and re-arrange parts of my tweet, it duplicates all the text and puts it out of order. The tweet box is not even a <textarea>, it's a <div> stuffed full of <span> elements. Additionally, the tweet box <div> is nested over 40 layers deep in a massive pile of divs. As always, they're trying to be way too clever for their own good. I'm not at all surprised they need polyfills for that trash.
- the_gipsy 6y agoThis is so true. There is no need for any of that nonsense, for composing a tweet.
- gruez 6y ago>The tweet box is not even a <textarea>, it's a <div> stuffed full of <span> elements. ah yes, because webdevs love reimplementing widgets from scratch. that's no a problem in and of itself, but they also implement it half-assed, so you end up with gems like what OP described, or links being implemented as <a href="#"> with an onclick.
- Haydos585x2 6y agoI think you'd find most front-end developers don't love reimplementing widgets from scratch but instead are required to because designers, product owners and customers expect this sort of experience. I just don't think Twitter would remain competitive if it had the interface of Hacker News.
- theandrewbailey 6y agoTell that to Craigslist.
- 6y ago
- renewiltord 6y agoThat's awesome! Man, things on the front-end side are shaping up pretty nicely these days. Also Twitter is such an incredible product. I love it. It's one of the few curate-by-default (along with Instagram, another masterpiece) feeds one can have. If your feed sucks, only you are to blame. Beautiful.
- joegibbs 6y ago83% sounds really impressive but it’s only 13kb, which would make practically no difference to the end user at all unless you’re on dial-up.
- kumarvvr 6y agoThere is a significant benefit if you consider the billions of views their pages get every month. A lot of bandwidth saved. Lot of energy saved. Every reduction is good in my view.
- foxfired 6y agoAfter looking at my networks tab[1], I had misunderstood this. It's only the size of the polyfill that has been reduced. The page is still downloading 800KB of javascript. [1]:https://imgur.com/a/01LfeiW https://imgur.com/a/01LfeiW
- rasz 6y agoWouldnt you load appropriate polyfill bundle based on Browser UA string anyway?
- kangax 6y agoWe tried doing this at Facebook few years ago but decided not to bother due to an insignificant effect on user metrics like TTI (time to interaction), FCP (first content paint), etc. 14KB is nothing when you're shipping 1MB+ of JS and all the other assets.
- tuananh 6y ago1MB+ gzipped JS? That's a lot