steveklabnik / turbolinks_test

Seriously. Use numbers.
http://blog.steveklabnik.com/posts/2012-09-27-seriously--numbers--use-them-
71 stars 14 forks source link

Getting TL measurements that include load time for sub-resources #4

Open benweint opened 11 years ago

benweint commented 11 years ago

First off, I want to say that it's great to see performance tests made public like this, so thanks to everyone who helped put it together!

Something's been bugging me with regard to measurement of Turbolinks performance. I'm interested mainly in the capture of page loading time via browser instrumentation 'in the wild', but I think the issue applies just as much to offline measurement.

For a normal page load, the 'load' event is not fired (from my understanding) until the top-level resource and all of its critical sub-resources are actually loaded (including, for example, images embedded in the page body). For a page load via Turbolinks, there doesn't appear to be an equivalent event to hook. The 'page:load' event emitted by Turbolinks is not sufficient for this purpose, because it fires before the critical sub-resources of the newly swapped-in body are loaded.

Some experimentation in Chrome suggests that new 'load' events are not fired on window or on the new body element, and I don't really know where else to look. Does anyone have any suggestions as to how to place a finish line on Turbolinks testing that's analagous to the traditional DOM load event, or other approaches to capture the time needed to load sub-resources referenced from the new body?

steveklabnik commented 11 years ago

No idea. You should post to rails-core. — Sent from Mailbox for iPhone

On Fri, Mar 22, 2013 at 12:58 PM, Ben Weintraub notifications@github.com wrote:

First off, I want to say that it's great to see performance tests made public like this, so thanks to everyone who helped put it together! Something's been bugging me with regard to measurement of Turbolinks performance. I'm interested mainly in the capture of page loading time via browser instrumentation 'in the wild', but I think the issue applies just as much to offline measurement. For a normal page load, the 'load' event is not fired (from my understanding) until the top-level resource and all of its critical sub-resources are actually loaded (including, for example, images embedded in the page body). For a page load via Turbolinks, there doesn't appear to be an equivalent event to hook. The 'page:load' event emitted by Turbolinks is not sufficient for this purpose, because it fires before the critical sub-resources of the newly swapped-in body are loaded.

Some experimentation in Chrome suggests that new 'load' events are not fired on window or on the new body element, and I don't really know where else to look. Does anyone have any suggestions as to how to place a finish line on Turbolinks testing that's analagous to the traditional DOM load event, or other approaches to capture the time needed to load sub-resources referenced from the new body?

Reply to this email directly or view it on GitHub: https://github.com/steveklabnik/turbolinks_test/issues/4

benweint commented 11 years ago

Thanks, @steveklabnik - I'll try there!

schneems commented 11 years ago

@benweint hey, i see you didn't get much reply from the post, maybe making an example app to show the problem with repro instructions could help? It looks like we might need some hooks in the turbolinks code, but I haven't touched any of it :/

mariovisic commented 11 years ago

I wrote a little gem which extends Newrelic to provide this functionality with PJAX: https://github.com/mariovisic/newrelic-pjax

It works by sending data to newrelic only after all of the images have loaded on the page. It seems to work well for my usage. I'm currently looking at modifying it to work with turbolinks for a new project.

If anyone else has already done something like this, please let me know :) it'll save me some time!

mariovisic commented 11 years ago

@benweint I'd actually be interested in having a chat about this, One problem I have is that the browsers performance.timing figures would be for the original page load and not the actual turbolinks request. Does NewRelic do anything with that information? I can see that it gets sent in the RUM requests.

The only way I can think of fixing that is just to not send that information on turbolinks requests.

@benweint if you have some spare time and can have a chat ping me on skype, same username.