Preload
The Preload
element is a great resource for improving your application’s
performance and load time by preloading external content prior to
loading it through HTTP requests. Including a Preload
element instructs the container to
fetch data from an external source while the gadget is being
rendered.
This element is used in conjunction with the OpenSocial JavaScript
API method gadgets.io.makeRequest
, which fetches
data from external sources. When used with Preload
, the gadgets.io.makeRequest
method request will
return the content instantly.
For example, if the gadget will be making a request to http://www.test.com and we want to preload the content,
we’d set up the Preload
element in
the following way:
<ModulePrefs> <Preload href="http://www.test.com" authz="signed" /> </ModulePrefs>
Preload
has a few available
attributes, listed in Table 3-2, that allow
further levels of customization.
Table 3-2. Preload attributes
Attribute | Description |
---|---|
| The URL for the content that the container is to preload. This field is required. |
| The authorization type to
use when requesting the content. This field is used in
conjunction with the authorization field of the
|
Get Programming Social Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.