Comment by adrianmonk
5 hours ago
It helps that it's not very big. In the working demo, the image is 132x26, and the actual JPEG file size is about 2-4 kB (depending on the text).
So even on a 56k modem, it might take less than 1 second to load each image.
You could also optimize it so it skips intermediate images if the user types fast. Suppose the user mashes "12345" in a fraction of a second. You start loading "1.jpg" on the first keypress. When you've finished loading "1.jpg", the field contains "12345", so skip straight to loading "12345.jpg".
The demo page's JS doesn't seem to include any optimization code like that. It just updates the img src whenever the text changes. Yet my browser seems to do it automatically! If I mash several keys, the console network log shows only some intermediate images get loaded.
I guess the browser is smart enough to know that, by the time it would have started the download, the resource no longer exists in the page. I'm not sure if browsers ~20 years ago did this, but it would have been worthwhile given how slow networks were.
No comments yet
Contribute on Hacker News ↗