Speaker Deck

How late is later? A lazy loading solution on the edge between very clever and incredibly mad.

by Massimiliano Marcon

Published September 7, 2012 in Technology

Reducing the loading time of a web application is a well known problem. Developers need to make sure the browser only downloads the code that is strictly necessary to bootstrap the application and leave the rest for later. This is what we commonly call lazy loading.

But when is later? When is the right time to lazy load?

When users interact with our applications there is a good chance they won't use all the provided features. Why lazy load code that is not needed then? Front-end code can be logically split into 3 sets:

Code required to bootstrap.
Code needed for the core functionality. It should be lazy loaded as soon as the bootstrap code has been delivered and parsed.
Code that may not even be necessary, or that is required only when a particular feature is used, and is therefore strictly dependent on the actions users perform within the context of the application. This means that this code can/should be loaded on demand.
This talk shows how JavaScript code - functions and objects - can be delivered to the browser on demand, thus reducing the perceived loading time of a web application.

Video here: http://www.ustream.tv/recorded/25243564