O'Reilly logo

Mobile Web Performance Optimization by S. Niranga

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Performing actions optimistically

If one of your visitors on your website decided to leave a comment, they would click on a button that submits the form. When they do that, two actions take place. The form, using AJAX, sends a request to the server, and a loading graphic appears to notify the user that their submission is in the process. When the script hears back from the server that the task has been completed successfully, it updates the page alerting the visitor.

This is the way it's usually done, but maybe it's not the best way. This request, particularly on a high-latency network, can take several hundred milliseconds, which is a very noticeable delay for the person trying to submit their comment.

Instagram has taken a different approach to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required