A brief analysis and comparison of the CSS for Twitter's PWA vs Twitter's legacy desktop website. The difference is dramatic and I'll touch on some reasons why.

Legacy site *downloads* ~630 KB CSS per theme and writing direction.

6,769 rules
9,252 selectors
16.7k declarations
3,370 unique declarations
44 media queries
36 unique colors
50 unique background colors
46 unique font sizes
39 unique z-indices

https://t.co/qyl4Bt1i5x
PWA *incrementally generates* ~30 KB CSS that handles all themes and writing directions.

735 rules
740 selectors
757 declarations
730 unique declarations
0 media queries
11 unique colors
32 unique background colors
15 unique font sizes
7 unique z-indices

https://t.co/w7oNG5KUkJ
The legacy site's CSS is what happens when hundreds of people directly write CSS over many years. Specificity wars, redundancy, a house of cards that can't be fixed. The result is extremely inefficient and error-prone styling that punishes users and developers.
The PWA's CSS is generated on-demand by a JS framework that manages styles and outputs "atomic CSS". The framework can enforce strict constraints and perform optimisations, which is why the CSS is so much smaller and safer. Style conflicts and unbounded CSS growth are avoided.
How does the PWA do responsive design with 0 media queries? Modern responsive design is about conditionally rendering entire component trees, and making components adapt to their own dimensions. You need to use 'ResizeObserver' for that. Media queries in CSS aren't good enough.
In fact, putting state in CSS (:hover, @media, etc) is as much of a problem for dynamic web apps as putting state in the DOM. Removing state from style definitions simplifies coordinating changes to trees & styles, and opens the door to more native-feeling interactions.
The Twitter PWA is a good example of how a huge, highly dynamic app benefits from a simpler "styles in JavaScript" paradigm (powered by a subset of CSS) that is significantly more effective and reliable than working directly with CSS or CSS-in-JS.

More from Tech

On Wednesday, The New York Times published a blockbuster report on the failures of Facebook’s management team during the past three years. It's.... not flattering, to say the least. Here are six follow-up questions that merit more investigation. 1/

1) During the past year, most of the anger at Facebook has been directed at Mark Zuckerberg. The question now is whether Sheryl Sandberg, the executive charged with solving Facebook’s hardest problems, has caused a few too many of her own. 2/
https://t.co/DTsc3g0hQf


2) One of the juiciest sentences in @nytimes’ piece involves a research group called Definers Public Affairs, which Facebook hired to look into the funding of the company’s opposition. What other tech company was paying Definers to smear Apple? 3/ https://t.co/DTsc3g0hQf


3) The leadership of the Democratic Party has, generally, supported Facebook over the years. But as public opinion turns against the company, prominent Democrats have started to turn, too. What will that relationship look like now? 4/

4) According to the @nytimes, Facebook worked to paint its critics as anti-Semitic, while simultaneously working to spread the idea that George Soros was supporting its critics—a classic tactic of anti-Semitic conspiracy theorists. What exactly were they trying to do there? 5/

You May Also Like

Oh my Goodness!!!

I might have a panic attack due to excitement!!

Read this thread to the end...I just had an epiphany and my mind is blown. Actually, more than blown. More like OBLITERATED! This is the thing! This is the thing that will blow the entire thing out of the water!


Has this man been concealing his true identity?

Is this man a supposed 'dead' Seal Team Six soldier?

Witness protection to be kept safe until the right moment when all will be revealed?!

Who ELSE is alive that may have faked their death/gone into witness protection?


Were "golden tickets" inside the envelopes??


Are these "golden tickets" going to lead to their ultimate undoing?

Review crumbs on the board re: 'gold'.


#SEALTeam6 Trump re-tweeted this.
दधीचि ऋषि को मनाही थी कि वह अश्विनी कुमारों को किसी भी अवस्था में ब्रह्मविद्या का उपदेश नहीं दें। ये आदेश देवराज इन्द्र का था।वह नहीं चाहते थे कि उनके सिंहासन को प्रत्यक्ष या परोक्ष रुप से कोई भी खतरा हो।मगर जब अश्विनी कुमारों ने सहृदय प्रार्थना की तो महर्षि सहर्ष मान गए।


और उन्होनें ब्रह्मविद्या का ज्ञान अश्विनि कुमारों को दे दिया। गुप्तचरों के माध्यम से जब खबर इन्द्रदेव तक पहुंची तो वे क्रोध में खड़ग ले कर गए और महर्षि दधीचि का सर धड़ से अलग कर दिया।मगर अश्विनी कुमार भी कहां चुप बैठने वाले थे।उन्होने तुरंत एक अश्व का सिर महर्षि के धड़ पे...


...प्रत्यारोपित कर उन्हें जीवित रख लिया।उस दिन के पश्चात महर्षि दधीचि अश्वशिरा भी कहलाए जाने लगे।अब आगे सुनिये की किस प्रकार महर्षि दधीचि का सर काटने वाले इन्द्र कैसे अपनी रक्षा हेतु उनके आगे गिड़गिड़ाए ।

एक बार देवराज इन्द्र अपनी सभा में बैठे थे, तो उन्हे खुद पर अभिमान हो आया।


वे सोचने लगे कि हम तीनों लोकों के स्वामी हैं। ब्राह्मण हमें यज्ञ में आहुति देते हैं और हमारी उपासना करते हैं। फिर हम सामान्य ब्राह्मण बृहस्पति से क्यों डरते हैं ?उनके आने पर क्यों खड़े हो जाते हैं?वे तो हमारी जीविका से पलते हैं। देवर्षि बृहस्पति देवताओं के गुरु थे।

अभिमान के कारण ऋषि बृहस्पति के पधारने पर न तो इन्द्र ही खड़े हुए और न ही अन्य देवों को खड़े होने दिया।देवगुरु बृहस्पति इन्द्र का ये कठोर दुर्व्यवहार देख कर चुप चाप वहां से लौट गए।कुछ देर पश्चात जब देवराज का मद उतरा तो उन्हे अपनी गलती का एहसास हुआ।