up.script
Features to attach JavaScript behavior to HTML elements whenever they enter the page.
Register a compiler with up.compiler(). It can return a destructor that cleans up when the element is removed, or you register one with up.destructor(). Elements pass structured data to their compilers through an [up-data] attribute, which up.data() reads. Macros registered with up.macro() run before all other compilers, usually to set other Unpoly attributes on the element.
When your own code inserts HTML into the page, call up.hello() on the new element so its compilers run. Elements marked [up-asset] track your scripts and stylesheets, so Unpoly can notice when a new version was deployed.
Tracks an element as a frontend asset, usually JavaScript and stylesheets.
This event is emitted when frontend code changes while the application is running.
Registers a function to be called when Unpoly inserts a matching element.
Registers a function to be called when an element with the given selector is inserted into the DOM. The function is called with each matching element as a jQuery object.
Returns the data attached to the given element.
Attaches structured data to an element to be consumed by a compiler or event handler.
Registers a function to be called when the given element is destroyed.
Manually compiles a page fragment that has been inserted into the DOM by external code.
Registers a compiler that is run before all other compilers.
Registers a compiler that is run before all other compilers. The compiler function is called with each matching element as a jQuery object.
Configures defaults for script handling and asset tracking.
Tip Your coding agent can search these docs locally with the Unpoly agent skill