Check out a free preview of the full Blazingly Fast JavaScript course

The "Introduction" Lesson is part of the full, Blazingly Fast JavaScript course featured in this preview video. Here's what you'd learn in this lesson:

ThePrimeagen introduces the topic of JavaScript performance optimization. They discuss the misconception around premature optimization and the importance of thinking about efficiency. The instructor also mentions that the course will focus on using tools available in Chrome to identify bottlenecks and make performance improvements.

Preview
Close

Transcript from the "Introduction" Lesson

[00:00:00]
>> We're not gonna do really much of an intro, we're just gonna get moving. And so this is the only thing I really wanted to kind of point out and then a couple other things cuz I'm always off by one. But this is one of my favorite people out in the Twitter space is Casey Moratori, as he is called.

[00:00:14]
And I just wanted to read this bottom part, which says people start to use the word optimization as if it means thinking even briefly about how efficient something is. And at that point, quotes like, premature optimization is the root of all evil, are very damaging because they were not talking about that meaning of the word.

[00:00:31]
They were talking about hand optimizing assembly and stuff like that. There's no way Tony Hoare or Knuth would have ever told you number one on your list was premature optimization, yet that is what people started thinking it means. And so, you always hear this anytime you try to make something fast or you talk about making something quick, you hear the premature optimization is the root of all evil quote.

[00:00:52]
And perhaps, just perhaps, maybe not that correct. And so good thing to think about. Casey, if you wanna go give Casey you follow, good guy Casey, appreciated him. Welcome to JavaScript performance, is this an oxymoron? Maybe, maybe it's not, we'll find out. So anyways, fast is kind of relative, so that term doesn't mean anything.

[00:01:13]
So if you're gonna make JavaScript fast, you can always have fast JavaScript. Now will JavaScript ever be as fast as Go or Rust? Probably not in our lifetime or anyone's lifetime, cuz it's just not the kind of language to go that kind of speed, but can it be fast comparatively?

[00:01:28]
Absolutely, you've seen all the bench markings in the world where one framework is five times faster than another framework, and you see it all the time. So fast does have meaning and we are gonna try to relatively make our JavaScript significantly faster, okay? And we're gonna have a lot of fun techniques and all that.

[00:01:45]
All right, so what is this course about? Well, it says much about JavaScript fundamentals as it is about performance. If you stick through the whole course, you're gonna learn a lot about how JavaScript hopefully works underneath the hoods. These skills will be partially transferable or mostly transferable to any GC-based language, because similar concepts exist kind of everywhere.

[00:02:03]
So if you go to Bun, same thing's gonna happen. You're gonna be able to apply a lot of the same techniques, cuz Bun is still JSC underneath the hood, which is still JavaScript. You'll be able to use some of these things in Go. And we're not gonna be talking about the DOM today.

[00:02:14]
This is not about how to make rendering order fantastic. This is not about any sort of paint optimizations, anything like that. You're gonna need to get Ken Wheeler in here if you wanna hear about that. It will hopefully make you write better code, because at the end of the day, things that feel really good are just awesome products.

[00:02:31]
If you've used Twitter on your phone and just in the Chrome browser, it crashes about every fourth time you use it. Because it runs out of memory and the thing just locks up and then it just completely explodes on your phone. And so that's really annoying. I want to be able to just use something without having it just completely hard shut down every single time.

[00:02:48]
We're not gonna deep dive into using the tool Perf or Chrome Tracing or VA Tracing. We may hit like tracing GC or trace GC as a node option for a moment. We're not gonna do anything into the deeper levels. And we're not gonna really talk about any micro optimization.

[00:03:02]
There's gonna be one moment where I'll show you a micro benchmark to make a point, but that is it. Micro benchmarks are largely deceiving. You can make pretty much anything look fast if you work hard enough with the micro benchmark. So we're not gonna be doing any of that.

[00:03:16]
And we're also gonna not do any sort of like, hey, when you create an object, always have your keys in the same order, always have the same types. We're not gonna be talking about that type of optimization either. That's a series of tricks that are applicable, that can be really, really good.

[00:03:28]
But in five years, are they still gonna be good? We don't know, we don't know what kind of new achievements there are. We don't know what, how things are gonna be done. Think about all the dumb things you used to do, like setting an array length to be zero.

[00:03:39]
Used to be the quickest way to empty an array rather than creating a new array. If you have short-lived objects, is that still a thing today? Probably not. And so it's like, now you have a whole different way you have to think about things, comparatively to the old wisdom of minusing length by one to pop something off as opposed to calling pop.

[00:03:58]
There's all sorts of dumb things that we used to do in JavaScript try to make it fast. So I don't wanna go over any of those things cuz they're not as exciting, right, and they just tend to fade. All right, long rambling intro, pretty much done, there you go.

[00:04:10]
Hopefully, everybody's excited about that.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now