K
K
kamlauka2018-08-07 17:26:19
JavaScript
kamlauka, 2018-08-07 17:26:19

Code optimization for weak computers?

How can I optimize the code so that the clouds do not slow down on weak computers:
https://codepen.io/kamlauka/pen/bjmNKV

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2018-08-07
@Stalker_RED

You have requestAnimationFrame there, that is, 60 fps. This is about 16ms per frame (1000/60).
You need to measure the time spent on rendering (Performance.now(), or even just new Date())
If it is comparable to 16ms, or more than 16, then you need to skip some frames. Output every second or every third.
The animation will not be as smooth, but there will be less brakes.
The second option: rewrite everything to css animation, what if it goes easier?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question