O'Reilly logo

Programming Social Applications by Jonathan LeBlanc

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

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

href

The URL for the content that the container is to preload. This field is required.

authz

The authorization type to use when requesting the content. This field is used in conjunction with the authorization field of the gadgets.io.makeRequest method. The values for this field are none (default), signed, or oauth. This field is optional.

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