Page 1 of 1

[Tip] Lazy Loading.

Posted: Wed Aug 24, 2011 8:03 pm
by calguy1000
Here's a tip for people that are updating their modules.

For a number of modules that display content, but may not be used on every page, I've enabled frontend lazy loading by merely adding this method:

function LazyLoadFrontend() { return TRUE; }

then bumping the version number.

The system should then load the module only when it's required. This will work fine for many cases. However, if the module provides classes for uses by other modules, or registers multiple plugins then lazy loading is probably not possible.

Additionally, if the module registers an event handler that is called on every page (like ContentPostRender)... then although the lazy loading should work, it's essentially useless as the module has to be loaded on every frontend request anyways. Another reason that that event should be used sparingly.

Just a tip for module developers.

Re: Lazy Loading.

Posted: Wed Aug 24, 2011 8:24 pm
by Jos
calguy1000 wrote:Additionally, if the module registers an event handler that is called on every page (like ContentPostRender)... then although the lazy loading should work, it's essentially useless as the module has to be loaded on every frontend request anyways.
Thanks for this explanation... was playing with this on Gallery and was wondering why it still was loaded despite the LazyLoadFrontend function

Re: Lazy Loading.

Posted: Wed Aug 24, 2011 8:27 pm
by Wishbone
My module (OwnersManual) is only used in the back end.. I assume that I should use Lazy Loading so that it doesn't get loaded on each front end page load?

Re: Lazy Loading.

Posted: Wed Aug 24, 2011 8:47 pm
by Jos
Yep, guess so...

And this will help: http://forum.cmsmadesimple.org/viewtopi ... =6&t=55055