API reference up.fragment
module

The JavaScript API to render, look up and destroy page fragments. Every link, form, overlay or poll that Unpoly handles ends in up.render(), and your own code can call it with the same options.

up.render() replaces elements on the current page with matching elements from a server response or an HTML string. up.navigate() does the same with the defaults of a user navigation, like updating history and scrolling to the new content. up.reload() fetches a fresh copy of a fragment from the URL it was loaded from, and up.destroy() removes a fragment, with an optional animation.

Lookup functions like up.fragment.get() differ from document.querySelector(): they only see the current layer, ignore elements that are playing out their exit animation, and understand Unpoly's own selectors like :main or :origin. Elements marked [up-keep] are kept across updates. For low-level DOM utilities that complement the browser's native API, see up.element.


Features