+ 1

How to speed up JavaScript ???

I created a site, but it works quite slowly, that I do not like at all :( Can I somehow speed it up??? https://code.sololearn.com/Wr5RiFVoW7bk/?ref=app

3rd Jan 2023, 6:45 PM
Артур Хромов
1 Respuesta
+ 9
Get rid of jQuery. You are not even using it but you still import the script. Every time the user clicks the button, you get a new image from a remote API. This takes time, even if it's just milliseconds. If you store the images locally (together with the actual website), that would probably already improve the situation. But in this code it is quite predictable what is going to happen. User clicks, get a new image. So what if you could be one step ahead of the user? When the page is opened, you could immediately fetch two images to memory. And when the button is clicked, just replace the image with the one that is already downloaded, and at the same time fetch the next. Like a tiny queue. If the user does not click like crazy, they could have an instant experience.
3rd Jan 2023, 7:03 PM
Tibor Santa
Tibor Santa - avatar