Custom Javascript

Let Unpoly pair HTML elements with your custom Javascript behavior. Your elements will automatically be compiled whenever a page fragment is updated.

page.html
<p>
  The time is <span class="timestamp"></span>
</p>
scripts.js
up.compiler('.timestamp', (element) => {
  var now = new Date()
  element.innerText = now
})