All language subtitles for 4-hydration-vs-resumability

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian Download
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: WEBVTT 1 00:00:00.003 --> 00:00:02.877 So we talked about hydration is being workaround, and 2 00:00:02.877 --> 00:00:07.138 I wanna really just kind of deep dive down on what kind of a crazy workaround it is. 3 00:00:07.138 --> 00:00:13.174 So, at the beginning we had HTML and we literally rendered a white page. 4 00:00:13.174 --> 00:00:14.949 There was nothing on it, right? 5 00:00:14.949 --> 00:00:18.533 And then we downloaded JavaScript, and then JavaScript would then execute 6 00:00:18.533 --> 00:00:22.231 the application, and the application would cause the rendering of the page, 7 00:00:22.231 --> 00:00:24.204 and then we would actually have the page. 8 00:00:24.204 --> 00:00:30.110 And it's at this point that the page would become interactive, right? 9 00:00:30.110 --> 00:00:35.681 And this was kind of ten years ago, if you look at how all of these frameworks 10 00:00:35.681 --> 00:00:41.350 worked before we had server-side rendering, right, this was the story. 11 00:00:41.350 --> 00:00:43.562 And so people said this is great but 12 00:00:43.562 --> 00:00:48.000 it is a horrible user experience that I have to look at a blank screen. 13 00:00:48.000 --> 00:00:50.919 So, let's do server-side pre-rendering. 14 00:00:50.919 --> 00:00:53.315 Once you do server-side pre-rendering, 15 00:00:53.315 --> 00:00:56.171 the HTML your shipping is actually bigger, right? 16 00:00:57.813 --> 00:01:02.241 And so now you get to see the page, but you can't interact with it. 17 00:01:02.241 --> 00:01:05.651 This is basically a picture of what you want, 18 00:01:05.651 --> 00:01:10.070 not the actual thing that you want, so it appears faster. 19 00:01:10.070 --> 00:01:15.576 So that's a win, but you still have to download the JavaScript. 20 00:01:15.576 --> 00:01:18.235 You have to execute the JavaScript. 21 00:01:18.235 --> 00:01:21.259 And now we are gonna use a fancy term reconcile, but 22 00:01:21.259 --> 00:01:23.450 it's really just a render, right? 23 00:01:23.450 --> 00:01:26.006 We literally did everything we had, and now at this point, 24 00:01:26.006 --> 00:01:27.294 we have the same exact thing. 25 00:01:27.294 --> 00:01:30.216 So if you think about what had just happened here, 26 00:01:30.216 --> 00:01:33.920 we threw this away and we replaced it with the same exact thing. 27 00:01:33.920 --> 00:01:38.424 And the reason why, you use the fancy word reconcile is because instead of throwing 28 00:01:38.424 --> 00:01:40.561 it away, we try to reuse DOM elements. 29 00:01:40.561 --> 00:01:44.592 Try being the operative word because if the DOM doesn't really fit what we want, 30 00:01:44.592 --> 00:01:45.966 we just rearrange things. 31 00:01:45.966 --> 00:01:47.240 And this actually happens. 32 00:01:47.240 --> 00:01:51.843 It turns out a lot of things that frameworks do will put, for example, 33 00:01:51.843 --> 00:01:55.822 a div inside of a button or a div inside of a paragraph turns out 34 00:01:55.822 --> 00:02:00.363 that's not allowed in HTML, and HTML will rearrange things on you. 35 00:02:00.363 --> 00:02:04.358 And then when the framework wakes up it just puts it back the way it was. 36 00:02:04.358 --> 00:02:06.868 So really this is a best case effort here. 37 00:02:06.868 --> 00:02:10.046 Anyways, so the fact that we are reusing the DOM elements is basically what 38 00:02:10.046 --> 00:02:11.367 the reconciliation comes in. 39 00:02:11.367 --> 00:02:13.986 But notice what happened this is the point where we can be interactive. 40 00:02:13.986 --> 00:02:15.677 And so we actually got slower. 41 00:02:17.731 --> 00:02:20.136 And this is kind of strange, don't you think? 42 00:02:20.136 --> 00:02:23.512 We wanted to be faster so we server-side pre-render, but 43 00:02:23.512 --> 00:02:25.546 we actually ended up being slower. 44 00:02:25.546 --> 00:02:28.323 And the reason for this is because there's duplication. 45 00:02:28.323 --> 00:02:33.564 We are sending the same information twice, once in the form of HTML. 46 00:02:33.564 --> 00:02:38.732 And then again, the same exact information form of JavaScript. 47 00:02:38.732 --> 00:02:43.190 And I really wanna stress this because if I was to delete this, 48 00:02:43.190 --> 00:02:47.239 HTML here or send a completely wrong HTML at this point. 49 00:02:47.239 --> 00:02:50.803 I would still end up in here, right? 50 00:02:50.803 --> 00:02:55.620 And so the JavaScript contains all of the information to render the page even 51 00:02:55.620 --> 00:02:58.490 though we already have it rendered, right? 52 00:02:58.490 --> 00:03:01.311 And that's because historically this is how we got here. 53 00:03:01.311 --> 00:03:06.859 We got here from this world of, hey, we do everything on the client and 54 00:03:06.859 --> 00:03:12.035 server-side rendering or the pre-rendering as it's called, 55 00:03:12.035 --> 00:03:17.417 right, is just a horrible workaround that it's kind of what it is. 56 00:03:17.417 --> 00:03:21.547 And this is why hydration is so slow because hydration doesn't do anything, 57 00:03:21.547 --> 00:03:24.596 right, it assumes blank page and does everything and yet 58 00:03:24.596 --> 00:03:26.325 it tries to reuse DOM elements. 59 00:03:26.325 --> 00:03:30.931 And some frameworks are better at it than others, so for example, 60 00:03:30.931 --> 00:03:34.396 SolidJS tries to remove a lot of the duplication. 61 00:03:34.396 --> 00:03:39.114 And so in the case of something like SolidJS, it's actually not possible to 62 00:03:39.114 --> 00:03:42.964 have a completely wrong HTML here it relies on many bits here. 63 00:03:42.964 --> 00:03:46.441 But fundamentally, that's the kind of mental model that we have. 64 00:03:48.524 --> 00:03:52.444 And that results in basically slow websites, right? 65 00:03:52.444 --> 00:03:53.936 Pick a website you want, 66 00:03:53.936 --> 00:03:58.712 and you'll basically discover that the performance is not as good as you want. 67 00:03:58.712 --> 00:04:01.635 So let's look at reasonability, how reasonability is different. 68 00:04:01.635 --> 00:04:04.748 So the above is basically what's happening today. 69 00:04:04.748 --> 00:04:06.619 We kind of talked about it in the previous slide. 70 00:04:06.619 --> 00:04:10.716 So we also start with HTML and it's about the same size because, well, 71 00:04:10.716 --> 00:04:14.148 we have to render the same exact page and so we get over here. 72 00:04:14.148 --> 00:04:18.543 What's different here is that this HTML includes a tiny bootstrap, which is about 73 00:04:18.543 --> 00:04:22.898 a kilobyte in size, piece of JavaScript, that's actually inlined in the HTML. 74 00:04:22.898 --> 00:04:27.085 And that one kilobyte is fixed, it doesn't get bigger no matter how complicated your 75 00:04:27.085 --> 00:04:30.415 website gets, it's like it's a fixed amount of cost that you pay. 76 00:04:30.415 --> 00:04:34.261 And because it's one kilobyte, we actually inline it into the HTML because we 77 00:04:34.261 --> 00:04:37.306 don't think it's worth making another stupid request for. 78 00:04:37.306 --> 00:04:41.705 And what it means is that the page is interactive at this point. 79 00:04:41.705 --> 00:04:47.585 If I click at this point, I am guaranteed that the click will be processed. 80 00:04:47.585 --> 00:04:49.118 Now, if I click over here, 81 00:04:49.118 --> 00:04:52.665 the click won't be processed it will just be dropped, right? 82 00:04:52.665 --> 00:04:55.319 So here you click on something and you're, well, what's going on here? 83 00:04:55.319 --> 00:04:58.970 Did I click too early or is the code not ready or what's going on? 84 00:04:58.970 --> 00:05:00.699 And you might have to click multiple times. 85 00:05:00.699 --> 00:05:02.363 Whereas here, the moment you click, 86 00:05:02.363 --> 00:05:05.122 you're guaranteed that eventually will be processed, yes? 87 00:05:05.122 --> 00:05:09.566 >> There's kind of an assumption built into when you say interactive and 88 00:05:09.566 --> 00:05:12.785 that's that it's JavaScript listener- >> Yes. 89 00:05:12.785 --> 00:05:15.165 >> That's processing the click. 90 00:05:15.165 --> 00:05:20.729 Your semantic anchors, your CSS only hover states things like that, 91 00:05:20.729 --> 00:05:24.231 that still would be active theoretically. 92 00:05:24.231 --> 00:05:28.248 And so I guess the differentiation here is still, 93 00:05:28.248 --> 00:05:32.180 I guess you're talking about JavaScript only. 94 00:05:32.180 --> 00:05:33.707 >> Yes, JavaScript interactivity. 95 00:05:33.707 --> 00:05:38.446 I'm talking about that in here when I click on a button, I am guaranteed that 96 00:05:38.446 --> 00:05:43.185 that button will be processed, now- >> But anchors, you could click on a link. 97 00:05:43.185 --> 00:05:45.945 >> Those things that do not require JavaScript, 98 00:05:45.945 --> 00:05:48.783 they would work obviously immediately, yes. 99 00:05:48.783 --> 00:05:52.716 >> Cool just wanted to clarify >> Yeah, no, that's a good clarification. 100 00:05:52.716 --> 00:05:55.773 Now when I say is that it's guaranteed to be processed, 101 00:05:55.773 --> 00:05:59.169 now at this point we haven't yet downloaded the JavaScript. 102 00:05:59.169 --> 00:06:03.492 So, depending whether JavaScript is in the cache or not, and we can go much 103 00:06:03.492 --> 00:06:07.762 deeper into that whole prefetching business, it is definitely faster. 104 00:06:07.762 --> 00:06:11.680 And then the next thing we have to do is we have to download the JavaScript. 105 00:06:11.680 --> 00:06:15.475 And if you click before the JavaScript is downloaded, then you may have to wait for 106 00:06:15.475 --> 00:06:16.692 JavaScript to download. 107 00:06:16.692 --> 00:06:19.161 If you click after the JavaScript is downloaded, 108 00:06:19.161 --> 00:06:21.110 your interaction is instant, right? 109 00:06:21.110 --> 00:06:24.439 But notice you couldn't even click at this point. 110 00:06:24.439 --> 00:06:26.329 You had to wait all the way over here, right? 111 00:06:26.329 --> 00:06:30.582 Whereas here, if you click here, you might have to wait a little bit, but if you 112 00:06:30.582 --> 00:06:34.858 click over here which would be equivalent to here, you're already way ahead. 113 00:06:34.858 --> 00:06:36.352 And so you say, Misko, but you're cheating. 114 00:06:36.352 --> 00:06:39.426 What happened to this box over here, right? 115 00:06:39.426 --> 00:06:43.961 Well, that box is the duplication that I removed, right? 116 00:06:43.961 --> 00:06:47.336 So here the thing we did, the reason why the amount of 117 00:06:47.336 --> 00:06:51.635 JavaScript we're downloading is so much smaller is because all of 118 00:06:51.635 --> 00:06:56.028 the bits that got duplicated when we generate the HTML is unneeded. 119 00:06:56.028 --> 00:07:00.645 And so worst case scenario is that the amount of JavaScript here is equal to 120 00:07:00.645 --> 00:07:02.141 JavaScript over here. 121 00:07:02.141 --> 00:07:05.016 That's the worst case scenario, right? 122 00:07:05.016 --> 00:07:07.465 But in practice that never happens and 123 00:07:07.465 --> 00:07:11.070 the amount of JavaScript you have is way, way smaller. 124 00:07:11.070 --> 00:07:16.145 The worst case scenario of being the same amount of JavaScript means that 125 00:07:16.145 --> 00:07:21.484 it is at this point where you are fully interactive with zero delay, right? 126 00:07:21.484 --> 00:07:27.162 This is the worst case scenario for us, probably will be even better than that. 127 00:07:27.162 --> 00:07:30.825 And even before the Java screen shows up, you already are guaranteed that if you 128 00:07:30.825 --> 00:07:33.733 click on something, the event will eventually be processed. 129 00:07:33.733 --> 00:07:36.840 So even in the worst case scenario, which is right here, 130 00:07:36.840 --> 00:07:40.272 we are way better than what you can possibly do with hydration, 131 00:07:40.272 --> 00:07:42.951 because we skip execution and reconciliation. 132 00:07:42.951 --> 00:07:45.691 And you say, well what happened to these two parts? 133 00:07:45.691 --> 00:07:49.341 And so these two parts are skipped because of something called resumability. 134 00:07:49.341 --> 00:07:51.402 And if you think about it, 135 00:07:51.402 --> 00:07:56.483 we cannot even do hydration at this point, even if we wanted to. 136 00:07:56.483 --> 00:07:59.964 Because hydration requires that we start at the root component and we go and 137 00:07:59.964 --> 00:08:03.180 visit all the components and collect information about the system. 138 00:08:03.180 --> 00:08:03.908 But guess what, 139 00:08:03.908 --> 00:08:06.980 huge amount of these components were never downloaded to the client. 140 00:08:06.980 --> 00:08:11.003 So even if we wanted to do hydration, we cannot, 141 00:08:11.003 --> 00:08:14.354 because the actual code is not present. 142 00:08:14.354 --> 00:08:18.565 We don't have the JavaScript to be able to even do hydration even if we wanted to. 143 00:08:21.129 --> 00:08:21.979 Okay, and 144 00:08:21.979 --> 00:08:28.039 removing this duplication is really the biggest win that we can have, yes. 145 00:08:28.039 --> 00:08:32.774 >> If quick adds listeners and state to the JSON. 146 00:08:32.774 --> 00:08:38.488 Would it have a problem with the kind of JSON bloating up kind of next? 147 00:08:38.488 --> 00:08:39.851 What happens with next? 148 00:08:39.851 --> 00:08:44.992 >> Yes, the question is because we serialize the state, right, 149 00:08:44.992 --> 00:08:51.308 to the JSON, will there become a problem for the start up of the application? 150 00:08:51.308 --> 00:08:54.949 Yes, the more complicated the page is, the more JSON you're gonna have, right, 151 00:08:54.949 --> 00:08:56.156 there's no way around it. 152 00:08:56.156 --> 00:09:01.009 But, couple of things, first of all you will never have more JSON than you 153 00:09:01.009 --> 00:09:03.924 would have in the case of Next.js, right? 154 00:09:03.924 --> 00:09:06.883 So Next.js would be the worst case scenario for us, right? 155 00:09:06.883 --> 00:09:10.707 So the industry standard for us is a worst case scenario. 156 00:09:10.707 --> 00:09:14.031 There are many times when the data would never actually have to be shipped, 157 00:09:14.031 --> 00:09:15.790 which as I kind of pointed out earlier. 158 00:09:15.790 --> 00:09:20.651 If we discover that a particular data is not editable, then we know it, 159 00:09:20.651 --> 00:09:22.117 don't even ship it. 160 00:09:22.117 --> 00:09:27.140 So for example, one demo I have is we do hack and use, and hack and 161 00:09:27.140 --> 00:09:32.276 use has all the data that shows all the comments that people make. 162 00:09:32.276 --> 00:09:34.894 None of those comments actually gets serialized into the JSON, 163 00:09:34.894 --> 00:09:36.257 because they're not editable. 164 00:09:36.257 --> 00:09:40.741 There's nothing you can do as a user in the UI that would cause you to 165 00:09:40.741 --> 00:09:43.156 rerender any of these components. 166 00:09:43.156 --> 00:09:46.603 And because the components cannot rerender, why are you shipping the data 167 00:09:46.603 --> 00:09:49.185 for something that can't possibly rerender, right? 168 00:09:49.185 --> 00:09:53.114 So in most cases, we can actually throw away most of the data. 169 00:09:53.114 --> 00:09:59.122 The second point to make is that this data is at the bottom of the HTML. 170 00:09:59.122 --> 00:10:03.094 So as soon as the HTML shows up, you see everything, right? 171 00:10:03.094 --> 00:10:08.068 Now, you might have to wait if you click on something before you see you might 172 00:10:08.068 --> 00:10:13.680 still have to wait for the HTML to finish downloading because there's bits below it. 173 00:10:13.680 --> 00:10:18.406 But you would have to wait for that anyways in the other cases, right? 174 00:10:18.406 --> 00:10:21.965 So basically the worst case of quick is the normal case for 175 00:10:21.965 --> 00:10:24.644 the other systems is what it comes down to. 176 00:10:25.955 --> 00:10:30.986 And in many cases we can do a lot better, so hopefully that answers the question. 177 00:10:30.986 --> 00:10:36.001 >> Yeah, so in other words, next we'll ship the state for 178 00:10:36.001 --> 00:10:41.175 things that can't be edited in [INAUDIBLE] >> Correct and the other 179 00:10:41.175 --> 00:10:46.564 thing to kind of point out is, when your app gets super large, we do have this idea 180 00:10:46.564 --> 00:10:52.296 of the microfonance where you can break your application into multiple containers. 181 00:10:52.296 --> 00:10:57.251 And these containers would allow you to kind of break the problem into 182 00:10:57.251 --> 00:10:58.539 smaller chunks. 183 00:10:58.539 --> 00:11:00.424 But those are super advanced use cases. 184 00:11:00.424 --> 00:11:02.439 In most cases, you just won't even have to get there. 185 00:11:04.794 --> 00:11:07.437 I'm wanna show you what this actually looks like in practice. 186 00:11:07.437 --> 00:11:12.698 So on the right-hand side, this is our homepage and we redid this homepage. 187 00:11:12.698 --> 00:11:15.154 Originally, it was in Next.js. 188 00:11:15.154 --> 00:11:18.499 And then when we did it in Quick, the right hand side, and 189 00:11:18.499 --> 00:11:22.840 the thing to kind of notice is just how quickly the page goes gray, right? 190 00:11:22.840 --> 00:11:28.442 The moment the HTML shows up, we render everything and it immediately goes gray. 191 00:11:28.442 --> 00:11:31.004 And then the other side shows up later and you say, well, wait a minute, 192 00:11:31.004 --> 00:11:32.351 they're both server side rendered. 193 00:11:32.351 --> 00:11:36.105 How come we're faster on the Quick side? 194 00:11:36.105 --> 00:11:39.352 Well because Quick can do an interesting trick. 195 00:11:39.352 --> 00:11:44.497 Quick can not ship the HTML below the fold. 196 00:11:44.497 --> 00:11:47.875 So the reason why the right hand side is actually even faster for 197 00:11:47.875 --> 00:11:51.778 the HTML is because we don't actually even ship the HTML below the fold. 198 00:11:51.778 --> 00:11:55.514 Is only when you start scrolling actually the HTML show up. 199 00:11:55.514 --> 00:11:59.952 And these are kind of the users cases that become trivial to do once you have 200 00:11:59.952 --> 00:12:01.035 resumeability. 201 00:12:01.035 --> 00:12:03.734 Because if something isn't interacted with, 202 00:12:03.734 --> 00:12:06.910 we don't even care whether the HTML's present or not. 203 00:12:06.910 --> 00:12:11.473 I mean, if you later put the HTML there because HTML is the source of the truth, 204 00:12:11.473 --> 00:12:14.672 we can just resume it later on when it shows up ,right? 205 00:12:14.672 --> 00:12:17.962 Something that you can't even do with existing frameworks, 206 00:12:17.962 --> 00:12:21.009 once hydration happens, everything has to be present. 207 00:12:21.009 --> 00:12:23.353 You can't just have part of the page. 208 00:12:23.353 --> 00:12:25.520 And so that's kind of the reason why that's faster, yes? 209 00:12:25.520 --> 00:12:30.580 >> So you said you don't even ship the HTML is below the fold. 210 00:12:30.580 --> 00:12:34.330 My question is, my tendency would be wanting to 211 00:12:34.330 --> 00:12:36.078 eagerly prefetch >> Yes 212 00:12:36.078 --> 00:12:38.983 >> Things that are one click away or 213 00:12:38.983 --> 00:12:41.249 one scroll action away. 214 00:12:41.249 --> 00:12:42.850 Can you decide? 215 00:12:42.850 --> 00:12:47.505 >> Yes, so this all comes to the business of how do you make sure you eagerly 216 00:12:47.505 --> 00:12:48.986 start fetching data? 217 00:12:48.986 --> 00:12:51.867 And there's a whole separate deep dive we can do it with it. 218 00:12:51.867 --> 00:12:54.237 Yes, obviously we prefetch all these things, right? 219 00:12:54.237 --> 00:12:57.419 So what's actually happening is that HTML shows up, 220 00:12:57.419 --> 00:12:59.398 the page is kind of finished, and 221 00:12:59.398 --> 00:13:04.367 in the background there's a service worker that starts doing all of these things. 20371

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.