There's really not much point in running a whole lot of performance tests on a development build, even though there are some benefits. If you want to see the improvements where the users are having problems, you need to use the same version of your app that the users are going to be working with. So that is why in the beginning, go ahead and make your minified production build, get it through all of your unit tests first to make sure there's no other bugs you need to work out. Because sometimes when those tests fail, they're showing you places like, hey, this spot might need some refactoring because it's overly complex, or maybe you have a bug in there that's hitting an API that returns a 404. And it just keeps making that request because you have it on some kind of, I don't know, time out, click the button type thing. But use production build so that you get the most accurate results. And the first thing, one of the most common things is that you'll be using lighthouse to just get that initial performance score. So using this app as an example, you see it has some modals, there's some different pages, functions, APIs, all that good stuff. And what this looks like on the page is just a little budget app, nothing too fancy. And I have not spent this much money in one day, just for the record. That's just some leftover data from some stuff I was playing with. But anyways, the main thing that y'all want to see would be Lighthouse. So this is a React app. We know that. But when you come into your developer tools and you go to the Lighthouse tab in particular, what you can do is set the different categories you want it to check for, and determine if your app is up to standards. So desktop isn't as hard to develop for, so I always run my reports for mobile. And as you can see in the background, Lighthouse does this cool thing. It goes ahead and puts it in a mobile view, and it runs all of these different performance tests to see, well, is your app running fast enough? Is it gonna work well for people with a slow internet connection? Is it accessible? Things like that. So as you can see, this app is pretty bad on performance, but the cool thing about Lighthouse is that down here they give you a lot of suggestions on what you can do to improve your app. So this first contentful paint, basically, how fast can you get your initial page load? Nine seconds is way too long. So I'll have to dig in and see what exactly is the problem. I'm guessing it has something to do with this graph, just a guess. But as you can see, they give you screenshots, they give you some different options, and this right here Minify JavaScript, that's why we run on a production build, but this is just a demo, so gotta show you what I can show you. But again, Lighthouse is a great tool, it gives you all of these tips and ideas of what you can do to make your app more performant. And so now that you've seen Lighthouse, if you're not familiar with the Profiler tool, but you have heard of the React Perf tool, this basically replaced that Perf tool. So there used to be some kind of React add-on that you could put in your code, and surround the particular component that you wanted to figure out how long it was taking to load with, and it would give you this whole report on, from the minute it starts rendering to the second it stops. But now that just happens in the browser, which is pretty awesome. So going back to our page, I'm clearing out everything. We'll go over here to this Profiler tab, which is really cool, but basically you can start profiling and refresh the page. It didn't profile for me.
Comments