Edit this page

up.fragment up.fragment.config
JavaScript property

Configures defaults for fragment updates.


[config.mainTargets=['[up-main]', 'main', ':layer']] Array<string> optional

An array of CSS selectors matching default render targets.

When no other render target is given, Unpoly will update the first selector matching both the current page and the server response.

When navigating to a main target, Unpoly will automatically reset scroll positions and update the browser history.

This property is aliased as up.layer.config.any.mainTargets.

[config.badTargetClasses] Array<stringorRegExp> optional

An array of class names that should be ignored when deriving a target selector from a fragment.

The class names may also be passed as a regular expression.

[config.navigateOptions] Object optional

An object of default options to apply when navigating.

[config.matchAroundOrigin] boolean optional

Whether to match an existing fragment around the triggered link.

If set to false Unpoly will replace the first fragment matching the given target selector in the link's layer.

[config.autoHistoryTargets] Array<string> optional

When an updated fragments contain an element matching one of the given CSS selectors, history will be updated with { history: 'auto' }.

By default Unpoly will auto-update history when updating a main target.

[config.autoScroll] booleanorstringorFunction(Element) optional

How to scroll after updating a fragment with { scroll: 'auto' }.

See scroll option for a list of allowed values.

The default configuration tries, in this order:

  • If the URL has a #hash, scroll to the hash.
  • If updating a main target, reset scroll positions.
[config.autoFocus] booleanorstringorFunction(Element) optional

How to focus when updating a fragment with { focus: 'auto' }.

See focus option for a list of allowed values.

The default configuration tries, in this order:

  • Focus a #hash in the URL.
  • Focus an [autofocus] element in the new fragment.
  • If focus was lost with the old fragment, focus the new fragment.
  • If updating a main target, focus the new fragment.
[config.runScripts=false] boolean optional

Whether to execute <script> tags in updated fragments.

Scripts will load asynchronously, with no guarantee of execution order.

If you set this to true, mind that the <body> element is a default main target. If you are including your global application scripts at the end of your <body> for performance reasons, swapping the <body> will re-execute these scripts. In that case you must configure a different main target that does not include your application scripts.

This website uses cookies to improve usability and analyze traffic.
I accept or learn more