In XPages when you look at the properties
of any control there are options for ‘Loaded’ and ‘Rendered’
The difference is very subtle, while
either of the properties will result in the control not displaying on the
XPage if they evaluate to false there are times where the ‘Loaded’ property
will result in a faster page for the end user. Here’s an example…
In my Advanced
XPages : A Nicer Domino Login Part 1 mini-series I have a custom
control that included a number of Dojo libraries, some extra JavaScript
and a Dojo dialog box. This code is only needed if the user of the site
is not logged in so why bother load it once the user is logged in?
As I have everything inside a custom
control I can set the ‘loaded’ or ‘rendered’ property on the page where
I have added the custom control. If I use the ‘rendered’ property then
the XPages processor still processes the custom control and even if the
rendered property evaluates to false the XPages processor will detect that
there are dojo libraries and extra resources to be loaded and will therefore
insert them into the html header of the generated page.
If you use the ‘Loaded’ property and
it evaluates to false the XPages processor will completely skip processing
the control and therefore the extra dojo libraries and resources are not
inserted into the html header and the resulting web page does not have
any extra deadweight so the page will load slightly faster.
So if you have a reason to load extra
resources in an XPage but only for special circumstances then consider
putting them into a custom control and use the ‘loaded’ property so that
they are only loaded when needed. Using this on my xTalk application I
reduced the page load from a 155KB, 4.7 Second load time to a 92KB, 1.2
Second load time ( with cache disabled ).
Just keep in mind that the loaded attribute is only evaluated once, so a partial (or even complete) refresh will not flip it to true, even if the condition for loading is now met… you have to use context.reloadPage() to get it to evaluate again (or navigate to another page and come back).
LikeLike
155KB/4.7 = 263.82 Kb/s92KB/1.2 = 613Kb/sDude… turn off the pr0n torrents in the background and get some throughput. 😛
LikeLike
My understanding was the same as Tim’s which means I pretty much never use the loaded property except in very special circumstances.But it is good to note the difference between the two properties.Matt
LikeLike