-
Notifications
You must be signed in to change notification settings - Fork 183
Request JS scripts with <link rel=preload...> #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…lways get the job done
|
BTW, I signed the CLA. Twice. Dunno what the problem is. |
|
CLAassistant is looking at the usernames of the committers, not the username of the PR creator. You committed with the @redfin-andrew-bartkus account, so that's the one that needs to sign the CLA. |
|
Very nice. The only thing I worry about is the I can think of a few other ways to toggle. Unfortunately, I don't think any would be as clean as what you've got here:
That last one's not pretty, but maybe the least ugly of the bunch? |
|
Given that the goal is to tell the client ASAP what JS to start downloading, I don't think there's any value in waiting for async data to turn this on. I was imagining that we'd enable this conditionally for some pages with a query param, eg, I'm struggling to think of a scenario where this is only valuable sometimes. It seems like it's either always valuable or never valuable. |
I place a pretty high value on the ability to dynamically control features at runtime using the aforementioned "bouncer" endpoint.
To be clear, this is async data that the preloads will be waiting on anyway (at Redfin) since
How about a script that I don't care about loading quickly? Presumably omitting that from preload would free up resources for other more important scripts? We currently have a single |
|
Talked with @bartkusa offline and ran some WPT tests against our details pages (specifically against this test page ) and got the following results from WebPageTest Without preload Performance Results (Median Run) With preload Which seems to imply that we're gonna improve our page load by 220 millis. |
|
200ms would be huge! 🚀 Still would like an interface that supports asynchronous opt-in and per-script opt-in. ;) |
|
I need to make some adjustments. This shouldn't merge in as-is. |
Something has been bugging me about our homepage's waterfall. Even though we use LAB.js to download our JS in parallel, sometimes the requests are delayed and/or serialized. I'm not sure it's a too-many-requests-to-our-CDN problem, and I'm not sure domain-sharding would fix it.
Here's a decent waterfall. The JS is downloading in parallel with the CSS, although, on connection 8, you can see that one JS file delays another. If you squint, you can see a delay between when connections 3 and 6 open up, and when the second JS file is requested on 8. But maybe that's just my imagination.
Waterfalls 2 is worse. There is an obvious missed opportunity to download JS files, and plenty of open connections.
Waterfall 3 is the worst. JS isn't requested until the CSS is nearly 100% completely downloaded.

I don't know what's causing this. Maybe I'm way wrong and this is solvable with domain-sharding. But maybe not. So why not try using
<link rel=preload>? Maybe it'll magically make browsers smarter and eagerly request stuff sooner.In the long run, maybe this can replace LAB.js; LAB is a lot of bytes in every request, bytes that could instead be HTML or inline styles or something more valuable.
I made it a config thing in React-Server, so pages can opt in, and we can individually measure any perf boosts (or lack thereof).