-
Notifications
You must be signed in to change notification settings - Fork 1
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
Purpose/Performance thoughts #13
Comments
Here's my $0.02...
Re: A few flavors... Personally, I wouldn't bother with this. Aside from being harder to maintain, it's cumbersome to choose and switch. I think the "live styles" option should either just be removed or I'd favor just having a |
@sorvell does #1 differ from https://github.com/bkardell/shadow-boxing? Or do you just prefer that one? Like, if we switch #1, what is left of half-light and how is it not just shadow-boxing? re: #4 ... This seems pretty reasonable I guess.. When? On DOMContentLoaded? |
Things I value about this approach:
|
Currently, half-light makes a few important decisions on how it works....
It uses a
@media
rule to keep everything valid and useable from CSSOM. This saves re-fetching or re-parsing (as well as the code it would take to do that which is huge) because everything is valid.It uses requestAnimationFrame to wait a beat for the body to become available before making sure rules come from the head and then collecting them all into the sets they might match. More or less this shouldn't fire until very shortly after it is and it could, in theory paint something
Right after 2, it attaches a mutation observer to the head. Again, the head should be closed/done - but if someone (rarely?) manipulates a style or link tag in the head after, it will work. For example, if you open devtools and edit rules in a
<style>
that should actually work as you expect.Creates a proxy(conceptually)/aspect around
.attachShadow()
which means that it can be pretty performant and work for whenever/however shadows are attached.... As long as it's done by calling that method. DSD does not, and so it doesn't work with DSD.Perhaps #3 is debateable. Someone mentioned that that gave them some pause about adopting it. It's not really fundamentally necessary for many/most use cases I guess. It sure makes it nice when you want to play around with dev tools or a code pen or something though.
Is #4 the right tradeoff? @knowler was mentioning (I think) that you could walk the tree and check for shadow roots, and that would support DSD. I guess we could just provide a method you could call manually when ready and it would happen late, just once and that would support DSD? It would be hella efficient I guess, but have bad FOUC and wouldn't handle anything live? I'm not sure that's a set of tradeoffs I would make myself though -- another option could be to just use a mutation observer on body instead - it's less efficient maybe by a lot, but almost all mutations just bail out because you're just checking for a shadow root and this is a thing a lot of polyfills do.. and it would work with DSD, not late.
So... What are we going for here? I'm debating maybe even just making a few flavors of the script because none of them are very complicated... I could use more thoughts before I make any updates to these though.
The text was updated successfully, but these errors were encountered: