p5-plack-debugger icon indicating copy to clipboard operation
p5-plack-debugger copied to clipboard

Improve timing for AJAX initialization/handling

Open stevan opened this issue 10 years ago • 3 comments

  1. The Plack.Debugger javascript gets loaded
  2. The Plack.Debugger hooks into the jQuery global AJAX handlers which send events (_:ajax-send, _:ajax-complete), however the consumer of these events is not handling them yet.
  3. The Plack.Debugger sends off an AJAX request to get the debugging data for the current page (and with that, find out if it needs to handle any AJAX requests or not)
  4. Another AJAX call happens on the page triggering the jQuery global handlers which in turn trigger our events (which are not yet being handled)
  5. The Plack.Debugger AJAX call in #3 succeeds and it loads the data and then turns on AJAX request handling (with the _:ajax-tracking-enable event).

stevan avatar Oct 06 '14 09:10 stevan

I can see two possible solutions to this problem right now, not 100% sure which is the best approach yet though.

  • We buffer all un-handled AJAX calls within our jQuery global hooks and then once AJAX handling is enabled we process that buffer.

or

  • We load the debugging data synchronously ({async : false}) essentially blocking the other AJAX requests from coming in before we know if we want to handle them.

The former is likely the "correct" way to do this, but the later is easier and debatably no less "correct" just not as nice.

stevan avatar Oct 06 '14 09:10 stevan

The first one can be easily accomplished using $.Deferred, I can take a look at it once I finish with lazy rendering.

Lapple avatar Oct 12 '14 19:10 Lapple

Keep in mind please that we are trying to support jQuery 1.2.6 at the earliest and 1.4.1 at the latest, so $.Deferred might not be an option.

Sent from my iPhone

On Oct 12, 2014, at 21:19, Aziz Yuldashev [email protected] wrote:

The first one can be easily accomplished using $.Deferred, I can take a look at it once I finish with lazy rendering.

— Reply to this email directly or view it on GitHub.

stevan avatar Oct 13 '14 06:10 stevan