Edit this page

up.link up.deferred.load(placeholder, [options])
JavaScript function


General

placeholder
required

The [up-defer] placeholder to load.

[options]
optional

Render options that should be used for loading the placeholder.

Unpoly will parse render options from the given placeholder's attributes. You may pass this additional options object to supplement or override options parsed from the placeholder attributes. See [up-follow] for a list of supported attributes.

Common options are documented below, but most options for up.follow() may be used.

Targeting

[options.target=':origin']
optional

A selector for the fragment to render the content in.

By default the [up-defer] element itself will be replaced with the loaded content. For this the element must have a derivable target selector.

You may target one or multiple fragments. To target the placeholder itself, you can use :origin target instead of spelling out a selector.

string

Request

[options.url]
optional

The URL from which to load the deferred content.

Defaults to the placeholder's [up-href] or [href] attribute.

string
[options.headers={}]
optional

An object with additional request headers.

Unpoly will by default send a number of custom request headers. E.g. the X-Up-Target header includes the targeted CSS selector. See up.protocol for details.

[options.background=false]
optional

Whether to load the deferred content in the background.

Background requests will not show the global progress bar.

boolean

Caching

[options.cache]
optional

Whether to read from and write to the cache.

With { cache: true } Unpoly will try to re-use a cached response before connecting to the network. To prevent display of stale content, cached responses are reloaded once rendered. If no cached response exists, Unpoly will make a request and cache the server response.

With { cache: 'auto' } Unpoly will use the cache only if up.network.config.autoCache returns true for the request.

With { cache: false } Unpoly will always make a network request.

boolean
[options.revalidate]
optional

Whether to reload the targeted fragment after it was rendered from a cached response.

With { revalidate: 'auto' } Unpoly will revalidate expired responses.
This behavior can be configured with up.fragment.config.autoRevalidate(response).

With { revalidate: true } Unpoly will always revalidate cached content, regardless of its age.

With { revalidate: false } Unpoly will never revalidate cached content.

booleanstring
[options.revalidatePreview]
optional

A preview that that runs while revalidating cached content.

stringFunction(up.Preview)
[options.expireCache]
optional

Whether existing cache entries will be expired with this request.

Expired content remains in the cache, but will be revalidated with the server after rendering.

By default, any non-GET request will expire the entire cache. This can be configured with up.network.config.expireCache.

To only expire some requests, pass an URL pattern that matches requests to uncache. You may also pass a function that accepts an existing up.Request and returns a boolean value.

booleanstring
[options.evictCache]
optional

Whether existing cache entries will be evicted with this request.

By default, Unpoly will never evict entries while the cache has space, preferring expiration instead. This can be configured with up.network.config.evictCache.

To only evict some requests, pass an URL pattern that matches requests to uncache. You may also pass a function that accepts an existing up.Request and returns a boolean value.

booleanstring

Return value

A promise that fulfills with an up.RenderResult once the deferred content has been loaded and rendered.