For the complete documentation index, see llms.txt. This page is also available as Markdown.

Deferred attribute resolving

Deferred attribute resolving prevents browsers from requesting unresolved bound values. It supports attributes such as `src` and `srcset` across supported components.

Documentation

Some attributes, such as image-related src and srcset, cannot use data binding directly because the browser tries to immediately fetch images when it encounters them during HTML parsing.

At that point, the data binding has not yet been resolved, and the request to an invalid source results in an error.

<ff-template>
    <!-- Causes an error while the browser is parsing HTML. -->
    <img src="{{imageURL}}">
</ff-template>

Eventually, src would be resolved and the image displayed correctly, but the initial error during HTML parsing is undesirable.

To avoid this error, image binding should be used. However, a limitation of image binding is that it only works for the src attribute and only for the ff-record, ff-suggest-item, and ff-asn-group-element elements.

A more general solution

Deferred attribute resolving offers a more general and flexible solution that also expands to the ff-template and ff-asn-group-element elements.

At its core, it works the same as image binding, but it allows you to specify any attribute to resolve in the deferred fashion.

This feature is available on the following elements:

  • ff-record

  • ff-suggest-item

  • ff-asn-group-element

  • ff-template

Elements that use the native <template> tag to define their templates should not be affected by premature browser requests.

However, there might be web crawlers that ignore it and try to follow the link or image source nonetheless. This could result in unwanted entries in the crawler's index.

You might want to check what a crawler actually indexes and then decide whether you need deferred attribute resolving, or apply it always for simplicity.

Setup

Place the data-ffw-defer attribute on the ff- element in which you want to use deferred attribute resolving.

The attribute takes a comma-separated list of all attributes you want to resolve indirectly.

Inside the ff- element, place the counterpart attributes with the relevant data binding.

They follow this pattern:

For the src and srcset attributes, this would look like:

Fallback in case of attribute name collisions

If you are already using attributes that follow the above naming pattern, an alias is available that is functionally identical. It only adds ffw- to its name.

You can use the regular attribute and the alias at the same time. In this case, only the alias will be resolved by Web Components.

Last updated

Was this helpful?