Nicolas
@necolas 2 years, 3 months ago 1781 views

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/
Here’s some Mac mini, iPad Pro, MacBook shots


https://t.co/C9W4D96e2K


https://t.co/qa6JsO8zbE


Here’s an interesting rig - MacBook screen sharing a Mac mini which is running Xcode and testing suite which auto runs app on several devices - personal build server. You could never connect the mini to a display from moment of purchase, ever


If you cover the Face ID camera it will tell you it’s covered and where the camera is located with an on screen arrow

You May Also Like

🚨🚨🚨 ALERT ALERT 🚨🚨🚨

NOW HEAR THIS NOW HEAR THIS

EVERY SINGLE ONE OF MY FOLLOWERS MUST RT THE FOLLOWING THREAD TO MAKE IT GO VIRAL.

THIS NEEDS TO GET OUT *RIGHT THE HECK


As Wictor was saying, this was an attempt to frame the Saudis. Guy connected to an AQ terrorist who attempted to ASSASSINATE Mohommad Bin Salman is the *source* for these Kashoggi stories.

If this had been known *from the beginning* we wouldn't have gotte 3 days of media hysteria over an attempt to frame Mohmmad Bin Salman and Saudi Arabia for Kashoggi's disappearance.

The media's MAIN SOURCE for these stories about the disappearance of Khashoggi is an underling of the Al Queda guy that tried to ASSASSINATE the Saudi's Crown Prince Mohammad Bin Salman a few years ago.

The media has been HIDING this until now....
About a month ago, I said to Jeffrey Toobin that it was Mike Flynn—not Paul Manafort—who had the *most* to offer Robert Mueller on the collusion question, underscoring that Flynn's December 2017 plea deal gave Mueller far more than we ever realized. Now here we are, 10 months on.


2/ Trump had two opportunities to formally name Flynn and his co-conspirator Erik Prince to his NatSec team during the 2016 campaign—he declined to do so *both times*. In the criminal justice system this is evidence of consciousness of guilt. Trump knew what these men were doing.

3/ That Trump sought out Flynn—not the other way around—in August '15, and began using him as his chief NatSec adviser right away, but never put him on his National Security Advisory Committee is critical evidence that Flynn was working on projects that had to be "off the books."