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.includes('2g')
}

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

Event properties

event.target
required

The link element that will be preloaded.

Type: Element
event.renderOptions
required

An object with render options for the preloading.

Listeners may inspect or modify these options.

Type: Object
event.preventDefault()
required

Prevents the link from being preloaded.