Use of HTTP headers for pre-loading core scripts #2719
Replies: 4 comments 13 replies
-
It's a great concept! We need the education around the gains and tradeoffs, so that each consumer can decide what's best for them. Currently, milo has no way of interfering with the render pipeline until late into the fold. Which shifts the development and maintenance cost on the consumers. The potential pitfall I see are future changes, which could lead to a performance degradation as assets that aren't needed are loaded. I have an idea with which we could shift the maintenance & compatibility aspects towards milo core, rather than each consumer and will trial that soon. |
Beta Was this translation helpful? Give feedback.
-
I'd also love your thoughts on this @overmyheadandbody @Ruchika4 @chrischrischris @rgclayton @auniverseaway. In my own testing I could verify that Megan's results were accurate and reproducible. In my mind, we would enact this on our Thank you in advance! |
Beta Was this translation helpful? Give feedback.
-
Given the limitations of headers & helix 4 measured against what milo needs to do, I would maybe solve this a different way. With the headers approach, there's a one-size fits all for where you pull milo from. What works for production doesn't work for hlx.page. I would try to write a small function that can live in head.html that can properly detect the context of the origin and then load the correct file from the correct origin. Almost to the point of minifying our getLibs function and placing it in head. Where it's not in the headers (boo), it gives us something maintainable that will work across the various places we load milo. For decorate, I think we keep making this more complicated than it needs to be. From a purity perspective, it makes sense that decorate.js lives as a separate file, but we keep tripping over ourselves with the chaining problem. There's nothing wrong to share a function out of marquee.js that others can use. All problems related to decorate.js chaining go away. |
Beta Was this translation helpful? Give feedback.
-
Thank you @auniverseaway and @overmyheadandbody for your feedback, it is much appreciated. Here is a compare showing how I might modify the head.html to enact the changes Megan was making: adobecom/bacom@stage...head-prefetch-test I think to your point Chris, it is probably time for us to create a ticket to refactor decorate.js so that it doesn't cause the chaining problem you mention. That to my mind is a better solution than preloading the entirety of decorate.js for the sake of the LCP. I put a very similar version of our If you have time, would love to see what you think, and then I might start having our team test this. Thank you again! |
Beta Was this translation helpful? Give feedback.
-
Hi All,
I wanted to bring this subject up for @meganthecoder because she is on PTO, and I am slated to discuss it in our next performance meeting.
@meganthecoder saw some pretty drastic results and performance increases by using HTTP Headers to preload "core" styles and scripts as seen in her work in this ticket: https://jira.corp.adobe.com/browse/MWPW-154060.
Essentially, Megan used the
headers.xlsx
file in the.helix
folder to create headers setting certain files to preload, allowing both milo and consumerstyles.css
,utils.js
,scripts.js
, anddecorate.js
to load in tandem. According to the results of her testing, she was able to save on average 800ms.Though effective, Megan points out that this is not necessarily the best way to do it, since the urls had to be hardcoded. However, Megan does mention the possibility of using
head.html
in order to programmatically figure out the domain, or that this performance change could be made to account of production alone. There are also considerations of bandwidth contention and possible side effects of using the preload scanner to fetch these files, but in her testing the pages seemed to work correctly and gained a net savings for performance.Considering some of the discussion around performance, flexibility, and consumer patterns versus milo core patterns, (see #2493 and https://github.com/orgs/adobecom/discussions/2390) we wanted to see what the greater community thought of this.
Thank you for your time!
Beta Was this translation helpful? Give feedback.
All reactions