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

You May Also Like

#தினம்_ஒரு_திருவாசகம்
தொல்லை இரும்பிறவிச் சூழும் தளை நீக்கி
அல்லல் அறுத்து ஆனந்தம் ஆக்கியதே – எல்லை
மருவா நெறியளிக்கும் வாதவூர் எங்கோன்
திருவாசகம் என்னும் தேன்

பொருள்:
1.எப்போது ஆரம்பித்தது என அறியப்படமுடியாத தொலை காலமாக (தொல்லை)

2. இருந்து வரும் (இரும்)


3.பிறவிப் பயணத்திலே ஆழ்த்துகின்ற (பிறவி சூழும்)

4.அறியாமையாகிய இடரை (தளை)

5.அகற்றி (நீக்கி),

6.அதன் விளைவால் சுகதுக்கமெனும் துயரங்கள் விலக (அல்லல் அறுத்து),

7.முழுநிறைவாய்த் தன்னுளே இறைவனை உணர்த்துவதே (ஆனந்த மாக்கியதே),

8.பிறந்து இறக்கும் காலவெளிகளில் (எல்லை)

9.பிணைக்காமல் (மருவா)

10.காக்கும் மெய்யறிவினைத் தருகின்ற (நெறியளிக்கும்),

11.என் தலைவனான மாணிக்க வாசகரின் (வாதவூரெங்கோன்)

12.திருவாசகம் எனும் தேன் (திருவா சகமென்னுந் தேன்)

முதல்வரி: பிறவி என்பது முன்வினை விதையால் முளைப்பதோர் பெருமரம். அந்த ‘முன்வினை’ எங்கு ஆரம்பித்தது எனச் சொல்ல இயலாது. ஆனால் ‘அறியாமை’ ஒன்றே ஆசைக்கும்,, அச்சத்துக்கும் காரணம் என்பதால், அவையே வினைகளை விளைவிப்பன என்பதால், தொடர்ந்து வரும் பிறவிகளுக்கு, ‘அறியாமையே’ காரணம்

அறியாமைக்கு ஆரம்பம் கிடையாது. நமக்கு ஒரு பொருளைப் பற்றிய அறிவு எப்போதிருந்து இல்லை? அதைச் சொல்ல முடியாது. அதனாலேதான் முதலடியில், ஆரம்பமில்லாத அஞ்ஞானத்தை பிறவிகளுக்குக் காரணமாகச் சொல்லியது. ஆனால் அறியாமை, அறிவின் எழுச்சியால், அப்போதே முடிந்து விடும்.