Links

HTML element <a> allows to navigate to a url. Library modifies this behavior to prevent a white flash. Request to server is made using Fetch API, and response body replaces the current document without a full page reload.

In some cases regular <a> behavior preserved:

Methods from the list above can be used in markup. When you need to keep regular <a> behavior in JavaScript - call method Event#preventDefault inside your click event handler for an appropriate element.

Event flow

  1. A <a> element triggers native click event in browser
  2. Library triggers ajaxify:fetch event and starts AJAX request
  3. When the AJAX request ends library dispatches ajaxify:load event with the response object
  4. If ajaxify:load wasn't prevented triggers ajaxify:render event and updates content of the <body> element

Take a look at the Custom Events section to read about dispatched events in more details.