What is this page about?

Attributes, by Finsweet, offers a free series of Solutions that provide essential features to improve your Webflow websites.

Inject Components

Keep components in sync across websites and inject components inside of Rich text elements

Solution • Flash Card

Copy Script

For advanced users familiar with this solution. Includes all attributes from this page. Click on attributes and values to copy them.

Required attributes

Source Element

Add to any element

fs-inject-element
=
"
element
"

Target Element

Add to Div Block or Rich Text Element

fs-inject-element
=
"
target
"

Inject Rich Text Position

Add to Rich Text element

fs-inject-position
=
"
VALUE
"

Inject Source

Add to the Target element
Not needed if the source element is on the same page as the target

fs-inject-source
=
"
PATH
"

Inject Instance

Add to Source and Target elements

fs-inject-instance
=
"
IDENTIFIER
"

Optional attributes

Resets Webflow Interactions

Add to Target element

fs-inject-resetix
=
"
true
"

Prevent Injecting CSS

Add to source element

fs-inject-css
=
"
false
"

Prevent Automatic Source Element Rendering

Add to source element

fs-inject-render
=
"
false
"

CORS Proxy

Add to source element

fs-inject-proxy
=
"
PROXY_URL
"

Disable Caching

Add to source element

fs-inject-cache
=
"
false
"

Caching for Non-Webflow Sites

Add to source element

fs-inject-cachekey
=
"
CACHE_KEY
"

Cache Version

Add to source element

fs-inject-cachekey
=
"
VALUE
"
1

Add this <script> inside the <head> tag of your page or project

This script is the universal Attribute script: you only need to include it once, even if you have multiple Attribute solutions on the page. Learn more . It must be placed on the page containing the target element.

<script async type="module"
src="https://cdn.jsdelivr.net/npm/@finsweet/attributes@2/attributes.js"
fs-inject
></script>

Copy Script
2

Choose the method you want

2

Add these required attributes to the elements

Source Element

Defines the element that should be injected elsewhere
fs-inject-element
=
"
element
"

The Inject solution lets one element act as a source and another as a target—whether on the same page, a different page, or even a different site. When the page containing the target loads, the source element is copied into it.

The fs-inject-element="element" attribute marks an element for injection.

This element will be moved from its original position and inserted into the destination defined by the fs-inject-element="target" attribute.

Add this attribute:
Name
fs-inject-element
Copy
Value
element
Copy
Add it to any type of element
Any element

Target element

Defines the location where the source element will be injected.
fs-inject-element
=
"
target
"

The fs-inject-element="target" attribute is used on the destination element that should receive the content marked with the source attribute.

  • If the target element is a Div Block, the source element is injected directly inside it.
  • If the target is a Rich Text element, the source is injected into its content. By default, it appears at the top. For more precise positioning, read the fs-inject-position documentation below.
Add this attribute:
Name
fs-inject-element
Copy
Value
target
Copy
Add it to these types of elements
Div Block
Rich Text
IMPORTANT

When the source element and target are on different pages, the <script> must be loaded only on the page where the target is.

NOTE

The element marked as the target can be placed anywhere:

  • On the same page as the source, which is useful for moving elements like a marketing banner into a CMS blog post
  • On a different page of the same website
  • On a page of another website, whether or not it’s built in Webflow
Only required when injecting an element from another page or website

Inject Source

Defines where the target will find the source element
fs-inject-source
=
"
PATH
"

The fs-inject-instance="source" attribute must be set on the target element. It tells the target from where to pull the source element.

  • if not set, the target expects to find the source element within the same page
  • if set with a relative path, such as /style-guide or ../resources/style-guide, the target expects to find the source element on these pages, on the same website
  • if set with a full URL, the target expects to find the source element on that site and page
Add this attribute:
Name
fs-inject-source
Copy
Value
PATH
Copy
Examples:
fs-inject-source = "/style-guide"
fs-inject-source = "https://site.com/style-guide"
Add it to an element with
fs-inject-element="target"
NOTE

This attribute is not needed if the source element is on the same page as the target.

Only required when injecting an element from another page or website

Inject Instance

Defines the unique ID that links the source element to the target
fs-inject-instance
=
"
IDENTIFIER
"

The fs-inject-instance="IDENTIFIER" attribute must be added to both the source element element and the target element.

It establishes the relationship between the two.

Add this attribute:
Name
fs-inject-instance
Copy
Value
IDENTIFIER
Copy
Add it to BOTH of these elements
fs-inject-element="element"
fs-inject-element="target"
NOTE

This attribute is not needed if the source element is on the same page as the target, and if there's no other elements and targets to match on that page. Defining it anyway is considered good practice, as it adds clarity during maintenance.

NOTE

The fs-inject-instance attribute enables the use of multiple source elements and targets.

Any combination is supported—multiple elements can be injected into one target, one element can be injected into multiple targets, or multiple elements into multiple targets. As long as instances and sources are correctly defined, the solution will work.

3

Publish your project and check out the result on the live site.

* Attributes Solutions must be tested on the published site after each change. They do not run in Design, Edit, or Preview mode.

Check more elements and settings below
Optional

Add more

settings

Rich Text Automatic Position

Defines a strategy for auto placement of the element in the Rich Text
fs-inject-position
=
"
VALUE
"

The fs-inject-position attribute is only applicable when the source element is injected on a Rich Text element. It's set on the Rich Text element that's tagged with fs-inject-element="target".

The VALUE defines where inside the Rich Text's body the element must be placed:

  • A value from 0 to 100 representing the percentage depth within the Rich Text body.
  • a keyword representing a preset:
    • first or start:0%
    • one-quarter: 25%
    • one-third: 33%
    • middle: 50%
    • center: 50%
    • half: 50%
    • one-half: 50%
    • two-thirds: 66%
    • three-quarters: 75%
    • end or last: 100%
Add this attribute:
Name
fs-inject-position
Copy
Value
VALUE
Copy
Add it to an element with
fs-inject-element="target"
Add it to this type of element
Rich Text
NOTE

Position several elements into one Rich Text element

If several elements have matching instance IDENTIFIER with a Rich Text element, a comma-separated list can be used to set their respective position.

If the source includes three elements, the attribute can be setlikethis: fs-inject-position="first, 40, three-quarters"

In this example, the first element is injected at the start of the Rich Text, the second at 40% of its length, and the third at 75%. The elements are injected in the order they appear in the source page's DOM.

NOTE

fs-inject avoids placing elements immediately after a heading. If the target position falls directly after a heading, the element will be injected just before it instead.

Rich Text Manual Position

Defines precisely where the element is injected in the Rich Text element

Source elements can be injected at a specific location within a Rich Text element by placing a shortcode directly in the text content.

The format is {{ELEMENT_IDENTIFIER}}, where ELEMENT_IDENTIFIER must match the value used in the fs-inject-instance="IDENTIFIER" attribute on the source element.

For on-page source elements

  • Components that are present in the same page can be used as{{ELEMENT_IDENTIFIER}}

For source elements on an external-page

  • Source elements that are published on an external page can be expressed as:{{ELEMENT_IDENTIFIER="/RELATIVE_URL"}}
    or {{COMPONENT_IDENTIFIER="https://ABSOLUTE_URL"}}
Add this shortcode within the RT text
Code
{{ELEMENT_IDENTIFIER}}
Copy
Examples:
{{marketing-banner}}
{{retarget-module="/modules"}}
{{infos="https://website.com/cross-site"}}
Add it to an element with
fs-inject-element="target"
Add it inside any element of this type
Rich Text
NOTE

Alternative manual positioning method

Instead of using the shortcode, you can manually position the source element by adding an Embed Code block inside your Rich Text element. Follow these steps:

  1. Inside the Rich Text element, insert a new line exactly where you want the source element to appear.
  2. Click the + icon and choose Embed Code.
  3. In the Embed Code block, add a <div> that defines the target location for your source element:
    <div fs-inject-element="target" fs-inject-instance="myinstance"></div>

This method gives you precise control over the injection point within the Rich Text content.

Resets Webflow Interactions

Fixes cases where Webflow interactions are not triggered
fs-inject-resetix
=
"
true
"

If your source element includes Webflow Interactions, you might find that these interactions don't work as expected after moving the element into the Rich Text element. This issue occurs because the Attributes script executes after the Webflow Interaction engine has already run.

To resolve this issue, add the fs-inject-resetix attribute with the value true to the Rich Text element. This action will reset and then restart the Webflow Interactions engine once the element is positioned inside the Rich Text, ensuring the element's interactions perform as intended.

Add this attribute:
Name
fs-inject-resetix
Copy
Value
true
Copy
Add it to an element with
fs-inject-element="target"

Prevent Injecting CSS

Prevents CSS to be injected along the source element
fs-inject-css
=
"
false
"

By default, the element 's CSS is imported and encapsulated inside a Shadow DOM to prevent style conflicts. This is required for external elements to retain their styling.

When elements are injected from the same Webflow project, the shared CSS is already available, so loading it again is unnecessary.

The fs-inject-css="false" attribute can be set to prevent unnecessary loading of the CSS when the elements is injected.

Add this attribute:
Name
fs-inject-css
Copy
Value
false
Copy
Add it to an element with
fs-inject-element="element"

Prevent Automatic Element Rendering

Let the developer in control of the rendering
fs-inject-render
=
"
false
"

When used, this attributes prevents the element to be automatically rendered.

Set to false, it will be up to the developer to render the element to the DOM. Set to true, it re-enables the automatic rendering.

Un-rendered elements can be accessed via the API.

Add this attribute:
Name
fs-inject-render
Copy
Value
false
Copy
Add it to an element with
fs-inject-element="element"

CORS Proxy

Fetch external documents that have CORS protection.
fs-inject-proxy
=
"
PROXY_URL
"

Defines a CORS proxy to be used to fetch external documents that have CORS protection.

Example:

fs-inject-proxy="https://api.finsweet.com/cors?url="

The external sources will be fetched like this:

https://api.finsweet.com/cors?url=https://example.com

Add this attribute:
Name
fs-inject-proxy
Copy
Value
PROXY_URL
Copy
Add it to an element with
fs-inject-element="element"

Disable Caching

Force refetching of source elements
fs-inject-cache
=
"
false
"

By default all external pages are cached to avoid refetching them on every navigation.

Users can disable caching by adding fs-inject-cache="false"

Add this attribute:
Name
fs-inject-cache
Copy
Value
false
Copy
Add it to an element with
fs-inject-element="element"

Caching for Non-Webflow Sites

Force refetching of elements
fs-inject-cachekey
=
"
CACHE_KEY
"

This option only applies when using the fs-inject attribute in a non-Webflow project, like Discourse.

To cache externally fetched documents, we have to define a database key for IndexedDB. In the case of Webflow projects, we use the Site ID as the database key, but for non-Webflow projects we need to manually define it.

Add this attribute:
Name
fs-inject-cachekey
Copy
Value
CACHE_KEY
Copy
Add it to an element with
fs-inject-element="element"

Cache Version

Determines the version for the cache
fs-inject-cacheversion
=
"
VALUE
"

This option only applies when using the fs-inject attribute in a non-Webflow project, like Discourse.

When defining a cache version, all fetched sources will be cached using it. If the cache version is bumped (never downgraded!), the cache will be invalidated and it will force a fresh request.

Defaults to 1.

Add this attribute:
Name
fs-inject-cachekey
Copy
Value
CACHE_KEY
Copy
Add it to an element with
fs-inject-element="element"
2

Add these required attributes to the elements

Element

Defines the element that should be injected elsewhere
fs-inject-element
=
"
element
"

The Inject solution lets one element act as a source and another as a target—whether on the same page, a different page, or even a different site. When the page containing the target loads, the source element is copied into it.

The fs-inject-element="element" attribute marks an element for injection.

This element will be moved from its original position and inserted into the destination defined by the fs-inject-element="target" attribute.

Add this attribute:
Name
fs-inject-element
Copy
Value
element
Copy
Add it to any type of element
Any element

Target element

Defines the location where the element will be injected.
fs-inject-element
=
"
target
"

The fs-inject-element="target" attribute is used on the destination element that should receive the content marked with the source attribute.

  • If the target element is a Div Block, the source element is injected directly inside it.
  • If the target is a Rich Text element, the source is injected into its content. By default, it appears at the top. For more precise positioning, read the fs-inject-position documentation below.
Add this attribute:
Name
fs-inject-element
Copy
Value
target
Copy
Add it to these types of elements
Div Block
Rich Text
IMPORTANT

When the source element and target are on different pages, the <script> must be loaded only on the page where the target is.

NOTE

The element marked as the target can be placed anywhere:

  • On the same page as the source, which is useful for moving elements like a marketing banner into a CMS blog post
  • On a different page of the same website
  • On a page of another website, whether or not it’s built in Webflow
Only required when injecting an element from another page or Webflow project.

Inject Source

Defines where the target will find the source element
fs-inject-source
=
"
PATH
"

The fs-inject-instance="source" attribute must be set on the target element. It tells the target from where to pull the source element.

  • if not set, the target expects to find the element within the same page
  • if set with a relative path, such as /style-guide or ../resources/style-guide, the target expects to find the element on these pages, on the same website
  • if set with a full URL, the target expects to find the element on that site and page
Add this attribute:
Name
fs-inject-source
Copy
Value
PATH
Copy
Examples:
fs-inject-source = "/style-guide"
fs-inject-source = "https://site.com/style-guide"
Add it to an element with
fs-inject-element="target"
NOTE

This attribute is not needed if the source element is on the same page as the target.

Only required when injecting an element from another page or Webflow project.

Inject Instance

Defines the unique ID that links the source element to the target
fs-inject-instance
=
"
IDENTIFIER
"

The fs-inject-instance="IDENTIFIER" attribute must be added to both the source element element and the target element.

It establishes the relationship between the two.

Add this attribute:
Name
fs-inject-instance
Copy
Value
IDENTIFIER
Copy
Add it to BOTH of these elements
fs-inject-element="element"
fs-inject-element="target"
NOTE

This attribute is not needed if the source element is on the same page as the target, and if there's no other elements and targets to match on that page. Defining it anyway is considered good practice, as it adds clarity during maintenance.

NOTE

The fs-inject-instance attribute enables the use of multiple source elements and targets.

Any combination is supported—multiple elements can be injected into one target, one element can be injected into multiple targets, or multiple elements into multiple targets. As long as instances and sources are correctly defined, the solution will work.

3

Publish your project and check out the result on the live site.

* Attributes Solutions must be tested on the published site after each change. They do not run in Design, Edit, or Preview mode.

Check more elements and settings below
Optional

Add more

settings

Resets Webflow Interactions

Fixes cases where Webflow interactions are not triggered
fs-inject-resetix
=
"
true
"

If your source element includes Webflow Interactions, you might find that these interactions don't work as expected after moving the element into the Rich Text element. This issue occurs because the Attributes script executes after the Webflow Interaction engine has already run.

To resolve this issue, add the fs-inject-resetix attribute with the value true to the Rich Text element. This action will reset and then restart the Webflow Interactions engine once the element is positioned inside the Rich Text, ensuring the element's interactions perform as intended.

Add this attribute:
Name
fs-inject-resetix
Copy
Value
true
Copy
Add it to an element with
fs-inject-element="target"

Prevent Injecting CSS

Prevents CSS to be injected along the source element
fs-inject-css
=
"
false
"

By default, the element 's CSS is imported and encapsulated inside a Shadow DOM to prevent style conflicts. This is required for external elements to retain their styling.

When elements are injected from the same Webflow project, the shared CSS is already available, so loading it again is unnecessary.

The fs-inject-css="false" attribute can be set to prevent unnecessary loading of the CSS when the elements is injected.

Add this attribute:
Name
fs-inject-css
Copy
Value
false
Copy
Add it to an element with
fs-inject-element="element"

Prevent Automatic Element Rendering

Let the developer in control of the rendering
fs-inject-render
=
"
false
"

When used, this attributes prevents the element to be automatically rendered.

Set to false, it will be up to the developer to render the element to the DOM. Set to true, it re-enables the automatic rendering.

Un-rendered elements can be accessed via the API.

Add this attribute:
Name
fs-inject-render
Copy
Value
false
Copy
Add it to an element with
fs-inject-element="element"

CORS Proxy

Fetch external documents that have CORS protection.
fs-inject-proxy
=
"
PROXY_URL
"

Defines a CORS proxy to be used to fetch external documents that have CORS protection.

Example:

fs-inject-proxy="https://api.finsweet.com/cors?url="

The external sources will be fetched like this:

https://api.finsweet.com/cors?url=https://example.com

Add this attribute:
Name
fs-inject-proxy
Copy
Value
PROXY_URL
Copy
Add it to an element with
fs-inject-element="element"

Disable Caching

Force refetching of source elements
fs-inject-cache
=
"
false
"

By default all external pages are cached to avoid refetching them on every navigation.

Users can disable caching by adding fs-inject-cache="false"

Add this attribute:
Name
fs-inject-cache
Copy
Value
false
Copy
Add it to an element with
fs-inject-element="element"

Caching for Non-Webflow Sites

Force refetching of elements
fs-inject-cachekey
=
"
CACHE_KEY
"

This option only applies when using the fs-inject attribute in a non-Webflow project, like Discourse.

To cache externally fetched documents, we have to define a database key for IndexedDB. In the case of Webflow projects, we use the Site ID as the database key, but for non-Webflow projects we need to manually define it.

Add this attribute:
Name
fs-inject-cachekey
Copy
Value
CACHE_KEY
Copy
Add it to an element with
fs-inject-element="element"

Cache Version

Determines the version for the cache
fs-inject-cacheversion
=
"
VALUE
"

This option only applies when using the fs-inject attribute in a non-Webflow project, like Discourse.

When defining a cache version, all fetched sources will be cached using it. If the cache version is bumped (never downgraded!), the cache will be invalidated and it will force a fresh request.

Defaults to 1.

Add this attribute:
Name
fs-inject-cachekey
Copy
Value
CACHE_KEY
Copy
Add it to an element with
fs-inject-element="element"

Still need help?