instructure / ic-ajax

ember-friendly jQuery.ajax wrapper
MIT License
167 stars 29 forks source link

Using request blocks web font loading? #41

Closed devinus closed 9 years ago

devinus commented 9 years ago

This happens on both Firefox and Chrome. Using a lot of request calls in setupController will make loading web fonts loaded in the <head> happen really late.

devinus commented 9 years ago
screen shot 2015-07-25 at 7 59 44 am

Notice how the AJAX calls before e.g. font loading and image loading, but it will make the font loading slower when it should be first-come, shouldn't it?

stefanpenner commented 9 years ago

Notice how the AJAX calls before e.g. font loading and image loading, but it will make the font loading slower when it should be first-come, shouldn't it?

FYI: you actually left out the timings, so i cannot come to the same conclusion as you.

devinus commented 9 years ago

@stefanpenner Why would the timings matter if it's async? AJAX requests should NOT make other things load slower, right?

stefanpenner commented 9 years ago

@stefanpenner Why would the timings matter if it's async? AJAX requests should NOT make other things load slower, right?

Yes, but i would love to see them. I feel like i am only being shown a list of files, that don't indicate the problem. My curiosity is getting the better of me, but now i feel like i dont have all the information.

stefanpenner commented 9 years ago

If you can provide a demo somewhere, it would be much easier to diagnose, rather then in the abstract.

I am doubltful that this is an ic-ajax problem, but am willing to investigate assuming i am provided some good starting point for diagnosis.

devinus commented 9 years ago

Here it is with timings:

screen shot 2015-07-25 at 8 51 05 am
devinus commented 9 years ago

@stefanpenner Ok, this is REALLY weird. If I add a loading substate to this route, it doesn't happen.

devinus commented 9 years ago

With a loading substate:

screen shot 2015-07-25 at 8 55 00 am
stefanpenner commented 9 years ago

Ah, you have hit the max number of active connections to anyone host (which is 6 in chrome).

You likely just want to be sure the image requests and fonts happen earlier, or move static assets to a different host (cdn, assets.domain.com) as it would get a new limit of 6 connections.

devinus commented 9 years ago

This is interesting. So because 6 is the limit, it is cycling through all the fired off requests in batches of 6 before finally getting to my webfonts which unfortunately don't fire until they're parsed in the page.

stefanpenner commented 9 years ago

yup this is how the browser works. You'll have to re-order or split across multiple hosts.