Advertisement
Guest User

Ghosts of Chrome Violations

a guest
Mar 20th, 2021
546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. A friend of mine made wrote this commit message
  2.  
  3. ---
  4. The journey starts with a simple `setInterval` function which is super naive and for some reason I decided to mutate the state directly like a caveman. Now the next wave of gainzzzz came up when I decided to clean up the state handling mess and actually clone and use `setState`.That did help quite a bit.
  5.  
  6. Even though it was kinda smoother, I still had all those shitty chrome render time violations showing up which was almost haunting me all daylong.
  7.  
  8. Not being satisfied with and due to the fear of the ghosts of chrome violations haunting me, I decided to go in search of enlightenment, and enlightenment did I find. Somewhere in the relics of the web there was a blog by Paul Lewis[https://developers.google.com/web/fundamentals/performance/rendering/optimize-javascript-execution]in which I learned about `requestAnimationFrame`. Now, I got to say,that was much better.The main difference between using `setInterval` and`requestAnimationFrame` was the in `setInterval` fired at weird intervals and if for some reason things mess up, our whole animation looks like shit. But when using `requestAnimationFrame` along with it being fired more frequently, it gave a timestamp which will let you at least sync up the animations even though you have dropped frames.
  9.  
  10. I was mostly happy. But alas, that happiness did not last long. I was still having dreams about the violation ghost haunting me. I went in search of a better life, a more meaningful one. And that is when I remembered that somebody sure has to have gone through this and got to have made a package, its javascript after all. I was not sure. The time was passing very soon and the darkness was closing in. I took a deep breath and started entering a bunch of words into a textbox whose paleness reminded me of my future if I could not solve this challenge that I have been chosen for. And as a God sent I saw that link in blue. It was as pretty as the oceans. But once I opened and saw that it was an old project that does not work for me I almost started loosing my hope. But, there wasanother(https://github.com/react-tools/react-move), another ocean of hope right below which when I opened looked mysterious (the docs were so weird that I almost lost it) but hopeful.My hands were shivering, breathing slowed down. I tried it out. It look like there is still hope. I started tearing apart my code, carefully placing the newly found hope in. At start it looked like I had been deep down in darked but after long long time working hard, there was a light.I went to the page, reloaded.
  11.  
  12. It was smooth as f**k.
  13.  
  14. THE END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement