šŸ‹ "RAIL", Important way of thinking about frontend performance

kaziusan

Kaziu

Posted on March 18, 2022

šŸ‹ "RAIL", Important way of thinking about frontend performance

šŸ˜Ž Don't guess, measure !

āŒ This is the reason why this website is slow !! I know it!
āœ… Well... I'm gonna just measure, drinking coffee

But after measuring performance, maybe you would think like that

šŸ˜‘ Hey, I measured... but I don't have goal! 1second? 2second? What is criterion??

šŸ˜Ž Ok I give you basic performance criterion, tadaaam RAIL
šŸ˜‘ Ruby on rails?
šŸ˜Ž No, there is no relationship with it at all, RAIL is based "Response, Animation, Idle, Load"

Content criterion time
Response 100ms
Animation 16ms
Idle 50ms
Load 1000ms

ā­ Response

some action should response less than 100ms, after user inputs something

Click! ----- less than 100ms -----> open modal
Enter fullscreen mode Exit fullscreen mode

ā­ Animation

Animation(video) is just collection of a lot of images actually. So it's important to know how many images there is in "A second"
Referenece video

content number of images in a second
TV 30
Movie 24
Game 60
PC 60

Now Let's do super easy math

1s - 60images
ā†“
16ms - 1image
Enter fullscreen mode Exit fullscreen mode

This is the reason why animation should finish less than 16ms

By the way this unit of How many images there is in a second is called FPS(Frames per seconds), so animation on PC is 60fps

ā–¼ for example, configuration of chartjs-plugin-streaming, there is "frameRate"
chat.js

ā­ Idle

After loading contents, looks like browser doesn't do anything, but still do something like getting data from API by XHR or lazy load images. These actions should be less than 50ms

šŸ˜€ click Url!
ā†“
šŸ˜€ finish rendering and we see something on browser!
šŸ˜­ wait, Im browser, I need to load images that I didn't on purpose at first
ā†“
ā†“ (50ms)
ā†“
šŸ˜­ Ok I've done it! I don't use main thread finally!
šŸ˜€ ohh I can handle now on browser now!!
Enter fullscreen mode Exit fullscreen mode

ā­ Load

loading time of webpage contents

I wanna see dev.io! click url!
ā†“
ā†“ (1 second)
ā†“
I see dev.io contents on browser and handle something as well!
Enter fullscreen mode Exit fullscreen mode

actually it's not necessary to load all contents at first.
Important thing is that loading contents in which user see on browser.

first view


ā†’ Next article "then how to measure them??"

šŸ’– šŸ’Ŗ šŸ™… šŸš©
kaziusan
Kaziu

Posted on March 18, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related