Skip to content

Instantly share code, notes, and snippets.

@schmijos
Created April 14, 2020 10:20
Show Gist options
  • Save schmijos/12090ed79932993b40d90bfce70eed4a to your computer and use it in GitHub Desktop.
Save schmijos/12090ed79932993b40d90bfce70eed4a to your computer and use it in GitHub Desktop.
Debug all Turbolinks events
@thedumbtechguy
Copy link

thedumbtechguy commented Oct 15, 2023

Recommend this.
Easier to maintain and makes it easier to view the logs.

eventNames = [
  'turbo:click',
  'turbo:before-visit',
  'turbo:visit',
  'turbo:submit-start',
  'turbo:before-fetch-request',
  'turbo:before-fetch-response',
  'turbo:submit-end',
  'turbo:before-cache',
  'turbo:before-render',
  'turbo:before-stream-render',
  'turbo:render',
  'turbo:load',
  'turbo:frame-render',
  'turbo:frame-load',
  'turbo:fetch-request-error',
]

eventNames.forEach(eventName => {
  document.addEventListener(eventName, (event) => {
    console.log(event.type, event);
  });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment