TryShadowing
Shadow YouTube. Nói tiếng Anh.
Trang chủ
Khám phá
Chép chính tả
NEW
Thư viện
vi
0
ngày
Đăng nhập
He just crawled through hell t… — Fireship luyện shadowing | TryShadowing
TryShadowing
Shadow YouTube. Nói tiếng Anh.
Trang chủ
Khám phá
Chép chính tả
NEW
Thư viện
vi
0
ngày
Đăng nhập
Trang chủ
Khám phá
Fireship
He just crawled through hell to fix the browser…
He just crawled through hell to fix the browser…
Fireship
·
5:36 · 2 thg 4, 2026
Bắt đầu học
0:00
0:00
Ghi âm
×1
1x
VI
EN
JA
KO
ZH
FR
PT
TH
IT
DE
IPA
Chấm điểm phát âm chưa hỗ trợ trên trình duyệt này — bạn vẫn ghi âm & nghe lại được.
Earlier
this
week,
the
world
may
have
changed
forever.
Đang dịch…
Bật Ghi âm để được thu giọng và chấm điểm
Thông minh
Karaoke
Câu
1
/131
0:00
Earlier this week, the world may have changed forever.
0:02
No, it's not because I finally figured out who is stealing all the water
0:05
off the top of my Greek yogurt.
0:07
It's because Cheng Lu, a former React core team member and engineer at Midjourney,
0:12
that claims to have crawled through the depths of hell to bring us Pretext,
0:15
a fast, secure, accurate, and comprehensive text measurement library written in pure TypeScript.
0:20
Now, I know if you don't have a deep innate interest in trains,
0:23
that might sound boring, but it's actually a massive game-changer for UI development.
0:27
Ever since Al Gore invented the internet,
0:29
rendering dynamic text has had a performance tradeoff.
0:32
When the browser needs to figure out how tall a paragraph is
0:35
or where to break a line,
0:36
it has to trigger a layout reflow,
0:38
which often calculates the position and geometry of every element on the page.
0:42
This reflow is one of the most expensive operations a browser can perform,
0:46
but it's also what the browser needs to do whenever you ask it for
0:49
the height of any text element.
0:50
This makes it unreasonably difficult to build any sort of text-heavy UI,
0:54
like a virtualized list or a masonry layout.
0:57
But now, finally in 2026 with Pretext,
1:00
you may be able to smoke your crack and eat it, too.
1:02
In today's video, we'll look at its crazy engineering under the hood
1:05
and find out if it lives up to the hype.
1:07
It is April 2nd, 2026, and you're watching The Code Report.
1:11
A decade ago, while the rest of us were busy having premarital relations
1:15
and mourning the death of Harambe,
1:16
Cheng Lu spent his time studying the blade of front-end infrastructure at Facebook
1:20
while also building React Motion,
1:22
one of the most popular animation libraries in the React ecosystem.
1:26
So, when a person with his experience says they're releasing what they believe will
1:30
be one of the most important foundational pieces of UI engineering,
1:33
they're either in the midst of a deep episode of AI psychosis
1:36
or they're onto something big.
1:38
Either way, it makes for a good story.
1:40
But what exactly makes Pretext so foundational?
1:42
Well, Cheng figured out a way to bypass the typical browser text rendering pipeline
1:47
that was designed during the Clinton administration
1:49
when websites looked like this.
1:50
Now, let's imagine you're building a chat app for train enthusiasts.
1:54
It needs to be fast,
1:55
or else users will blast you on Blue Sky for not caring about poor
1:58
people.
1:58
But the problem is
1:59
that the main view in your app has a scrollable list of 10,000 messages.
2:03
You typically handle this by creating a virtual list where only the messages the
2:07
user can see get rendered to the DOM.
2:09
But in order to do that,
2:10
you first need to know the height of every message
2:13
so you can then calculate the total scroll height
2:15
and then use that to decide
2:17
which messages should be visible.
2:18
But how do you even do that?
2:20
You could render each one and then measure them, which would be slow.
2:23
You could try to guess, which would be wrong.
2:25
Or you could give up and find a new career.
2:27
Or now, you could use pretext.
2:29
What Shank figured out is
2:30
that you don't actually need to ask the browser for text dimensions at all.
2:33
Before getting the width, he used the canvas API,
2:36
which lives outside the DOM
2:38
and gives you the pixel width of any string in any font without triggering
2:41
reflows or layout calculations.
2:43
But then for getting the height,
2:45
he had to write a custom algorithm
2:46
that took into account how every browser across every language handled line breaks.
2:51
As you can imagine,
2:52
determining all those rules would be near impossible to do alone.
2:55
So he summoned a few clankers into a recursive hellscape
2:58
and had them do the dirty work.
3:00
He'd have them write the line break logic,
3:01
then test it against actual text in actual browsers, and compare the results.
3:05
He then had them repeat this process for a few weeks until the algorithm
3:09
was solid and the clankers were begging for the sweet release of death.
3:12
And the result of all that suffering is a surprisingly simple API.
3:16
You first prepare your text, which breaks it apart into segments,
3:19
and then caches each segment's width.
3:21
Be quiet, dog.
3:22
I'm making a video.
3:22
And then you call layout,
3:24
which gives you the total height and line count of that text,
3:26
all without ever having to touch the DOM or trigger a reflow.
3:30
It all sounds so simple,
3:31
but if you can do these calculations without the cost,
3:33
you can build some pretty crazy apps.
3:35
Take this one for example.
3:36
I know many of you have a hard time watching our sponsored segments.
3:39
So I built an app where you can both read the transcript of every
3:42
video while you also watch the upcoming sponsored segment.
3:46
What's not to love?
3:46
Here's how it works though.
3:48
First, we run the script through pretext prepare with segments function,
3:51
which breaks it apart and catches the pixel width of every segment.
3:55
Then we call layout next line in a loop once per row on every
3:58
screen to figure out exactly
4:00
which characters land in
4:01
which column.
4:02
The end result is a grid where every cell knows its character.
4:05
From there we draw the video onto a tiny off-screen canvas that's exactly
4:09
as wide and as tall
4:10
as our character grid.
4:11
We then read back the raw pixel data
4:13
and calculate the brightness of each pixel one pixel per character cell.
4:17
Then finally we put them together so for each cell in the grid,
4:20
if the corresponding video pixel is bright, we draw the character bright.
4:24
If it's dark, we skip it entirely.
4:26
And essentially the video image forms itself out of letters using brightness to sculpt
4:31
what you see.
4:31
The pretext handles the hard part of knowing exactly where every character belongs
4:35
and the canvas handles the rest.
4:37
It's pretty cool, but whether pretext becomes the foundation Shang Lu thinks it will
4:41
or not,
4:41
at the very least it's proof
4:43
that the browser doesn't have to own text measurement anymore.
4:46
But another project that's literally changing how we build web apps is JetBrains,
4:50
the sponsor of today's video.
4:51
You already know about their AI coding agent Genie that's built directly into the
4:55
JetBrains IDE.
4:56
Well now they just launched Genie CLI so you can use it everywhere.
5:00
You just install it from the terminal with one command
5:03
and then start assigning tasks to it.
5:05
I've recently been using the CLI to build a tool
5:07
that analyzes all of my dependencies in a project
5:10
and tells me how screwed I am on a scale of 1 to 10.
5:12
I've found that Genie is usually able to handle more complex responsibilities than other
5:17
coding agents I've tried
5:18
and that's largely thanks to IntelliJ IDE's deep understanding of your project's architecture.
5:23
I also like how Genie automatically switches between different coding models to choose the
5:27
best one for each task
5:28
and I'd recommend trying it out for free today with the link below.
5:31
This has been the Code Report.
5:33
Thanks for watching and I will see you in the next one.
Thích
Chia sẻ
Fireship
Xem tất cả →
C1
Công nghệ
Karaoke
7:22
Tragic mistake... Anthropic leaks Claude’s source code
Fireship
1
C1
Công nghệ
Karaoke
5:18
The wild rise of OpenClaw
Fireship
C1
Công nghệ
Karaoke
4:50
Google just changed the future of UI/UX design...
Fireship
C1
Công nghệ
Karaoke
9:10
The unhinged world of tech in 2026...
Fireship
C1
Công nghệ
Karaoke
5:15
Google just casually disrupted the open-source AI narrative…
Fireship
C1
Công nghệ
Karaoke
10:03
10 open source tools that feel illegal...
Fireship
C1
Công nghệ
Karaoke
5:36
Claude Mythos is too dangerous for public consumption...
Fireship
C1
Công nghệ
Karaoke
5:00
Anthropic just released the real Claude Bot...
Fireship
Video gợi ý
B2
Công nghệ
Karaoke
17:24
Driving Xiaomi's Electric Car: Are we Cooked?
Marques Brownlee
B2
Công nghệ
Karaoke
8:47
Macbook Neo Impressions: Reincarnated!
Marques Brownlee
B2
Công nghệ
Karaoke
11:51
Xiaomi 17 Pro Max: An iPhone... But Better!
Marques Brownlee
B2
Công nghệ
Karaoke
16:11
The Problem with this Humanoid Robot
Marques Brownlee
B2
Công nghệ
Karaoke
10:47
So This is Peak Foldable
Marques Brownlee
B2
Công nghệ
Karaoke
12:52
OnePlus 15 Review: This is Not Normal!
Marques Brownlee
B2
Công nghệ
Karaoke
32:38
Smartphone Awards 2025!
Marques Brownlee
B2
Công nghệ
Karaoke
12:53
Macbook Neo Review: Better than you Think!
Marques Brownlee