-
Notifications
You must be signed in to change notification settings - Fork 273
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
Figure out how to publish a performant custom element #1
Comments
My (naive) guidance in this area is to keep-it-simple since this component is not using Shadow DOM things aren't too complex to leave in a developer's hands.
This should in theory be the simplest distribution method possible and give implementers absolute control where they need it. I'm working on this during my flight today, expect a PR in the next day or two (and other issues coming in as-needed for work later.) Update: PR #3 is open for anyone who wants to follow along to see updates as they happen. Once I'm solid on everything to support what I've done the PR description and title will be updated. |
@paulirish I have this blog post on how I think web components should be published: http://justinfagnani.com/2019/11/01/how-to-publish-web-components-to-npm/ But I also think that styles should be included in the JS so that they are installed automatically, rather than require any separate style imports, so it's not much help there. |
I think bundling the styles in from the JS directly partially comes down to Shadow DOM usage. If you're using it, then it seems fine since the engine is only applying those styles within that scope anyways. However in this situation, we do not have Shadow DOM in use, so the same styles affect every instance. It makes more sense to bundle the CSS separately and pay the cost once to apply it rather than every time a component is used on a page. |
Well... shadow dom should be used to encapsulate the styles to only these elements. Every browser that supports custom elements also supports shadow dom. |
I'm also going back on what I told you at CDS Paul. The current norm in web components is shipping with your module defining itself. Since we are not providing this as an exported module, we should go ahead and define the custom element in the script itself. I'll get that done and clean up what needs to be done tomorrow (or tonight after I get home and nap.) |
I need help here, this isn't my area of expertise. ;)
I don't love the idea that JS has to be run in order for the styles to be added to the page.
This thing should still look great if the JS is in a
<script async>
and delivered really late.What is the best practice for packaging a web component such that its straightforward for someone to npm install it but with styles built separately from the JS?
The text was updated successfully, but these errors were encountered: