API reference up.script
module

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.


Features