title: Time to fire for beforeunload vs. pagehide on iOS
body: <p>I'm using the <code>beforeunload</code> event to as a means to proxy into metrics about clicks on my site. For example, if <code>beforeunload</code> fires within ~50ms of a <code>click</code> event, I can determine when a user has selected a link.</p>
  
  <p>This gets complicated with iOS, as it doesn't support <code>beforeunload</code>. As per Apple docs, I've substituted <code>pagehide</code> for <code>beforeunload</code>, but this doesn't have the same functionality. It looks as if <code>pagehide</code> replaces <code>unload</code> - NOT <code>beforeunload</code>. In my tests their time to fire differs by ~1500ms on average (<code>pagehide</code> triggers much later than <code>beforeunload</code>). This makes attributing <code>pagehide</code> events to clicks very difficult.</p>
  
  <p>Is there any event supported by safari on iOS that can get close to the trigger time of <code>beforeunload</code>?</p>
  
  <p>NOTE: I know this isn't ideal, and there are other, better approaches which I will likely end up pursuing, but I was still curious about this.</p>