And what we can see here is that actually it's this parseHtml is taking up about 34% of our rendering times. And now we can start drilling into this. Maybe I'll make it a bit bigger for you. And we can drill in and say, well, it's coming from set in the HTML, which is within our cell component. So now that gives us a way of being able to say, well, actually, okay, I can go and check and see, well, what is the code that is causing this thing to happen? Because the other way you can see this is if you zoom all the way down here, zoom in, zoom in, you get your method names of what's being called. And then it's all these little blue boxes at the end is the parseHtml. So you can see if we can speed those up, we're going to speed everything up. And that's exactly what we were able to do.
If I load another profile. Oh, that's saving it. Sorry. This one. So after the change, and I'll show you the code that we actually changed, you can see things have really improved. And we've lost that method from this chart. So we can see, okay, we've done a good job. We've managed to identify what the slowest part is, and we managed to get rid of it. And this was the code change. We just simply changed from setting something from innerHTML to text content. Because when we weren't in React, we were managing these things ourselves. So innerHTML, just for a bit of context, it can accept a string which contains HTML elements in it. So there's added overhead here of checking what that string is, matching things and saying, do I need to parse it and turn it into some DOM elements. So if you're just setting text itself, it's much quicker to just use text content, because the browser is like, well, this is just a string, I'm just going to display it. And so in doing that, we got some massive performance improvements within the grid.
Another thing, which I guess is another area of performance that you might be interested in debugging, is if you see these big purple bars in your performance profile. So this one is called recalculating styles. And so you just the bar being there is quite disconnected from what actually caused the browser to have to recalculate. So you don't get this big blue arrow. This is me just trying to make it possible for you to see it, because it's here. But it's very thin. But what it will do is it will draw an arrow back to the code, which has changed the DOM in such a way or made a request for like a container height, that is then forced the browser to have to redraw all the layouts.
Comments