Replies: 8 comments 10 replies
-
thanks @yesil, sounds reasonable to me |
Beta Was this translation helpful? Give feedback.
-
I think it's a cool idea to have a common way of consuming Spectrum Web Components opt-in in a common fashion. |
Beta Was this translation helpful? Give feedback.
-
Great start to the conversation here. Exciting to see this moving in a direction that can be productive for various teams. Some areas of thought/questions to keep in mind as things continue to come together here... Is Milo consumption really served by a single theme configuration? @import url('@spectrum-web-components/styles/core-global.css');
@import url('@spectrum-web-components/styles/tokens/global-vars.css');
@import url('@spectrum-web-components/styles/tokens/spectrum/global-vars.css');
@import url('@spectrum-web-components/styles/tokens/spectrum/custom-vars.css');
@import url('@spectrum-web-components/styles/typography.css');
:host {
display: block;
}
#scale,
#theme {
width: 100%;
height: 100%;
}
@import url('@spectrum-web-components/styles/theme-light.css');
@import url('@spectrum-web-components/styles/tokens/light-vars.css');
@import url('@spectrum-web-components/styles/tokens/spectrum/custom-light-vars.css');
@import url('@spectrum-web-components/styles/scale-medium.css');
@import url('@spectrum-web-components/styles/tokens/medium-vars.css');
@import url('@spectrum-web-components/styles/tokens/spectrum/custom-medium-vars.css');
@import url('@spectrum-web-components/styles/tokens/spectrum/medium-vars.css'); This could also be pre-built/bundled into libs assets as shown in your PR and possibly save additional download/parse/compile time in a page load. Further nuance can even be achieved with appropriate consumption of media queries to get light/dark and mobile/desktop bifurcation a la https://github.com/adobe/spectrum-web-components/blob/main/projects/documentation/src/components/styles.css Does a practice here deserve a version management policy? **Relation between "source" files and "output" files?" Is it practical to attempt to normalize consumption patterns to reduce the need to additional documentation? Multiple registrations of the same name issues |
Beta Was this translation helpful? Give feedback.
-
EDIT: I did not see
so these comments don't apply (as much). --- OG comment -- Using spectrum web components would definitely increase developer productivity and prevent us from re-creating components. However, I think we should approach this very carefully. @yesil in your demos you show a lighthouse score of 100, but those are very simple non-real-world examples. The spectrum button by itself takes 60k. The current equivalent button in milo is apx 5k. Also by bundling everything for each component, all shared swc code is repeated in each file. I think that there may be some use cases for this:
Then again - even if it's not in Milo there's nothing stopping consumers from doing it for their project, as long as they recognize the potential overhead they are adding to the page. |
Beta Was this translation helpful? Give feedback.
-
Since using Spectrum comes with its own styles, what would happen in a scenario where Consonant styles differ from Spectrum's? What is the level of flexibility that Spectrum provides for on-demand changes like this? |
Beta Was this translation helpful? Give feedback.
-
Can we rather proceed to some tests with catalog pages @yesil? Obviously for admin/authoring purpose i think it's a great deal. But usage makes me think that yes our complex UI pages should probably use it. And yes, if it's just for a button, it's definitely not worth bringing it in. |
Beta Was this translation helpful? Give feedback.
-
I think this is a merch / plans area of concern and should be scoped as such. Milo shipping this as a generic solution implies we agree with the performance characteristics of SWC and we do not. Your "samples" are myopic and limited and do not accurately reflect the realities we operate in. From what I can see, none of your samples use any real-world blocks or milo in general. We can make bare pages all day long with React and call them performant, too. You are saying that a 60KB dependency to put a button on a page is performant? In Franklin land we typically say if you can get to LCP within 100KB, you should be OK as long as you don't ship any TBT. A single button here is 60% of that budget. The heart of milo (utils.js) is 11KB last I checked. If you have a 50KB LCP image plus this button, you're done... you're not going to be 100. That's not even including the page HTML, scripts.js, styles.css, or even Milo utils. Never would I say taking up 60% of a site's LCP budget for a single button is considered performant. I wouldn't base that opinion on your samples above, either. I think getting some better real world examples together that accurately reflect our realities and proving the case that a 60KB dependency for a single button is still going to net us 100LH would be a better use of everyone's time. And the samples should have these dependencies in LCP. They should not hide behind existing vanilla blocks. I also fail to see what this is actually buying you. We know from Dexter putting a dependency on Spectrum means we are no longer in control of behaviors. When they decide to zig when we need them to zag, we are at a disadvantage. I think there's a lot of accessibility wins to gain from SWC, but I don't think that is enough to warrant the significant overhead you're asking for. The question I always have is, "What happens first? Consonant / Milo buttons become as accessible as Spectrum or Spectrum ships performant components?" I don't envy the place they are in with a significant codebase and a lot of dependencies, but that's the reality we live in. Getting a performant version of Spectrum seems to be a long way off. I advocated before that vanilla merch cards that do not have high interactivity and state requirements do not need these types of dependencies and the commerce team still insisted on making everything a Web Component. So now, just to get a single card on a page, you need at the very least a 10KB Lit dependency. The list of anti-patterns here is numerous. I've stayed out of the way here as it relates to merch / commerce and will continue to do so. If you want to ship a 60KB button, go for it, but as the owner of Milo I won't bless this as some sort of supported pattern because I fundamentally do not agree with it. |
Beta Was this translation helpful? Give feedback.
-
All of our SPA needs thus far have been A) author facing, or B) contributed by another team (CaaS). For (A) Milo provides some UI controls that anyone can use. These have been used fairly extensively in our configurators. As the primary person who has built other SPAs on Milo, I haven't found a ton of value in most of the controls beyond the configurator use case. I think we're still early in understanding what we want our authoring experiences to be.
I think I have fully considered your proposal. As someone who is maybe your ideal customer, I'll pass on the offer to use SWCs in Milo. I don't think we (Milo) should willingly take on a 3rd party dependency that we know has performance issues. Not only this, but you're asking us to accept a solution we don't currently have a need for. You're also asking us to put an arbitrary build step in whenever there are changes or updates required. I think your commerce use cases are a different story...
I think using whatever you want for commerce is 100% fine. Do whatever helps you be successful. If that's bits of SWC, great. If that's WCs, great. If that's vanilla JS, that's great, too. I have long advocated that if it walks and talks like an SPA, you should build it like an SPA. You may not get our approvals, but we're also not going to request changes on your PR. UAR, CaaS, etc. all have or had performance problems and we didn't block those PRs. My recommendation is still the same as it has been for almost two years now:
|
Beta Was this translation helpful? Give feedback.
-
TLDR; this post proposes a way to consume Spectrum Web Components on Milo with focus put on the performance.
This is only for SPA pages and regular Milo pages will not be affected by this proposal should it be implemented.
A POC is available, link at the bottom.
Overview
Spectrum Web Components (SWC) provides some advanced UI components that are not available in the Consonant Library OOTB on Milo.
e.g: Sidenav, Menu, Search, Popover, custom Modals, etc.
Current Catalog, Plans and TWP pages are depending on those components and Milo version will ship with them as well.
SWC documentation doesn't provide guidance on how to optimize the dependencies, expect for bundling them all together.
In order to follow Milo philosophy with SWC where a component is loaded only when it is needed, I propose the following approach:
/libs/features/spectrum-web-components/button.js
Implementation
For each SWC component that we want to use, the developer adds a file (notice
src
in the path), e.g:/libs/features/spectrum-web-components/src/button.js
in which the necessarily imports and exports are added. Often it will be a single line file.
e.g:
button.js
import '@spectrum-web-components/button/sp-button.js';
Run
npm run build
atlibs/features/spectrum-web-components
, which generates small bundles containing individual swc components using esbuild.Add a test file for this SWC component, and PR Milo.
Performance
By optimising the number of resources and web-components imported we can reduce the impact on LCP considerably.
Tests
Test files contains one or multiple spectrum components and nothing else.
1. sp-theme + sp-button
URL: https://mwpw-139915--milo--yesil.hlx.live/sp-base.html
Resources: 4 files
Overhead: 60.9kb gzip
LH score: 100 (https://pagespeed.web.dev/analysis/https-mwpw-139915--milo--yesil-hlx-live-sp-base-html/mwvpubznb1?form_factor=mobile)
2 .theme + button + overlay + menu + popover + dialog
URL: https://mwpw-139915--milo--yesil.hlx.live/sp-build.html
Resources: 15 files
Overhead: 172kb gzip
LH score: 100 (https://pagespeed.web.dev/analysis/https-mwpw-139915--milo--yesil-hlx-live-sp-build-html/kfxgyro100?form_factor=mobile)
Catalog page(WIP):
https://mwpw-139915--cc--yesil.hlx.live/drafts/ilyas/catalog?milolibs=mwpw-139915-catalog--milo--yesil&martech=off#category=all
Source codes: https://github.com/adobecom/milo/compare/main...yesil:MWPW-139915?expand=1
Beta Was this translation helpful? Give feedback.
All reactions