Skip to content
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

[OPTIONAL]: TodoMVC built with Web Components #249

Merged
merged 41 commits into from
Jun 28, 2023

Conversation

flashdesignory
Copy link
Contributor

@flashdesignory flashdesignory commented Jun 20, 2023

This pr is a simple implementation of the todo app using native web-components (with shadow dom)..
This is a "backup" solution in case we want something in the workloads that uses web components extensively.

Notes:

  • this uses the proposed updated styles as well and therefore the dom structure itself is somewhat bigger.
  • Due to the usage of the shadow doms, I had to find a different way to target the elements in the tests
  • DOM structure is different compared to other todo apps
  • No build steps used to minify or bundle the app (I could minify the files at some point if need be)

Scores:
Chrome:
Screenshot 2023-06-20 at 3 08 56 PM

Firefox:
Screenshot 2023-06-20 at 3 09 10 PM

Safari:
Screenshot 2023-06-20 at 3 09 22 PM

Edge:
Screenshot 2023-06-20 at 3 09 32 PM

@kara

@bgrins
Copy link
Contributor

bgrins commented Jun 20, 2023

I suspect the Lit workload will cover similar technical ground, but we can always compare and contrast profiles.

@flashdesignory
Copy link
Contributor Author

I suspect the Lit workload will cover similar technical ground, but we can always compare and contrast profiles.

Yup, this is an alternate version to cover web components, in case we don't get the pr in time 😄

@rniwa
Copy link
Member

rniwa commented Jun 21, 2023

So interesting. With Lit workload (#251), browsers in the order of high score are: Chrome, Firefox, then Safari. With this workload, on the other hand, browsers in the order of high score are Safari, Chrome then Firefox with very little difference between Chrome & Firefox. This might be interesting / different enough workload to merit the inclusion based on that observation.

@julienw
Copy link
Contributor

julienw commented Jun 21, 2023

So interesting. With Lit workload (#251), browsers in the order of high score are: Chrome, Firefox, then Safari. With this workload, on the other hand, browsers in the order of high score are Safari, Chrome then Firefox with very little difference between Chrome & Firefox. This might be interesting / different enough workload to merit the inclusion based on that observation.

There are several questions:

  • which workload(s) are more typical of real-world usage?
  • what are the performance characteristics of this workloads compared to the lit-based one? Especially do you know why is Safari faring better here than in the other one? This could help us make a decision.

lit is clearly gaining a lot of traction lately (x3 more downloads on npm in a year)
I also know about Stencil which is more stable, but quite used otherwise.
Do you have evidence of developers using web components without a library?

@flashdesignory
Copy link
Contributor Author

@rniwa @rictic - using constructable styles makes a difference.
The latest push is using them..

Chrome before:
chrome_before

Chrome after:
chrome_after

Safari before:
safari_before

Safari after:
safar_after

Firefox before:
firefox_before

Firefox_after:
firefox_after

Copy link
Contributor

@julienw julienw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work, this looks pretty solid! Also it's pretty nice to finally have an example that uses esm without a build step. IMO this may be the biggest interest for this workload.

I added a few comments, I didn't add them everywhere they apply by simplicity but of course they apply in all similar code.

I'm not approving just yet because I'd like to see the code with these changes again. Please add new commits for the changes so that the new review will be easy to do :-)

flashdesignory and others added 6 commits June 27, 2023 10:50
…rc/components/todo-app/todo-app.component.js

Co-authored-by: Julien Wajsberg <[email protected]>
…rc/components/todo-app/todo-app.component.js

Co-authored-by: Julien Wajsberg <[email protected]>
…rc/components/todo-item/todo-item.component.js

Co-authored-by: Julien Wajsberg <[email protected]>
Comment on lines 23 to 24
this.htmlDirection = document.querySelector("html").getAttribute("dir") || "ltr";
this.shadow.host.setAttribute("dir", this.htmlDirection);
Copy link
Contributor

@julienw julienw Jun 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote in my previous comments that the same comments were applying to other files :-) can you fix those too?

  1. document.querySelector("html").getAttribute("dir") => document.dir
  2. this.shadow.host => this

In all components

Thanks :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes 🤦 - thanks!

Copy link
Contributor

@julienw julienw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fixes, looks good to me now

@flashdesignory flashdesignory merged commit 2281e13 into WebKit:main Jun 28, 2023
4 checks passed
@flashdesignory flashdesignory deleted the todo-wc branch June 28, 2023 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
non-trivial change A change that affects benchmark results
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants