š "RAIL", Important way of thinking about frontend performance
Kaziu
Posted on March 18, 2022
š 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
ā 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
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"
ā 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!!
ā 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!
actually it's not necessary to load all contents at first.
Important thing is that loading contents in which user see on browser.
ā Next article "then how to measure them??"
Posted on March 18, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.