Edit this page

up.link up:link:preload
DOM event

This event is emitted before a link is preloaded.

Listeners may prevent this event to stop the link from being preloaded, or change render options for the preload request.

Example

The following would disable preloading on slow 2G connections:

function isSlowConnection() {
  // https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation
  return navigator.connection && navigator.connection.effectiveType.include('2g')
}


up.on('up:link:preload', function(event) {
  if (isSlowConnection()) {
    event.preventDefault()
  }
})

Event properties

event.target Element

The link element that will be preloaded.

event.renderOptions Object

An object with render options for the preloading.

Listeners may inspect or modify these options.

event.preventDefault()

Prevents the link from being preloaded.