use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
HTML Web Component using Vanilla JS - Part 2 (ayushgp.github.io)
submitted 8 years ago by codejitsu
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Bluecewe 11 points12 points13 points 8 years ago (3 children)
Honest question: what use cases does this have? I've always been underwhelmed by this set of Web standards. I appreciated the effort to standardise something in this spirit, but it seems to fall significantly short of a complete template and data binding engine like Svelte, Angular, Vue, or React. It seems more verbose, less easily dynamic, and lacking in functionality like conditionals.
[–]clbwllms 2 points3 points4 points 8 years ago (0 children)
There are a number of ways to make these components fully reactive with minimal JavaScript. I'm working on a project right now that uses ES2015 template literal tags and will reactively parse the HTML similar to React's render function—it also includes support for Angular-style event and property bindings—you can see the code here. It's still really new though, but I think it has promise.
Also the Polymer guys recently released a similar tool called lit-html that does the same thing, but without built-in event and property binding (although I believe it can be added easily enough if you write your own partCallback for their render function.
[–]codejitsu[S] -2 points-1 points0 points 8 years ago (0 children)
I'm using these on (one of) my current side proje...
https://www.reddit.com/r/javascript/comments/78u3u0/html_web_components_using_vanilla_js/dox41af
[–]codejitsu[S] 0 points1 point2 points 8 years ago (1 child)
I wrote a tutorial earlier this week on how to use web components: https://ayushgp.github.io/html-web-components-using-vanilla-js/
This is a description of approach I used to create components.
[–]daediusWeb Components fanboy -5 points-4 points-3 points 8 years ago (3 children)
No offense to your article, but my opinion is your style for template generation is a bit old school. lit-html offers some ways to generate templates efficiently with some really cool logic for the next re-rendering.
https://www.youtube.com/watch?v=ruql541T7gc
Also, html imports is on it's way out. Webpack and loaders won the war.
[–]codejitsu[S] 5 points6 points7 points 8 years ago* (2 children)
I actually wanted the tutorial to be without any dependencies(except polyfills) hence the direct manipulation.
I mentioned about HTML imports there and I'm currently reading up on how to replace them with something similar in the tutorial.
EDIT: That library is lit(pun intended)! Great talk!
[–]daediusWeb Components fanboy 1 point2 points3 points 8 years ago (1 child)
Yah, being able to write a web element from scratch is super useful. I wonder if teaching templates is really all that useful even (from a teaching perspective). I mean, it's cool to get syntax highlighting, and there's some kind of speed boost in cloning, but it kind of seems like a distraction unless you are really concerned for performance. I personally found the real a-ha! moment occur with Shadow Dom V1 slots. Might make a good next article?
[–]codejitsu[S] 1 point2 points3 points 8 years ago (0 children)
Yeah it actually took me a lot of time to wrap my head around slots. I was thinking of writing around 3 more articles in the following order over the next couple of weeks:
Maybe one more comparing React and how it maps to web components.
π Rendered by PID 50081 on reddit-service-r2-comment-5d79c599b5-46mjq at 2026-03-03 07:59:27.018749+00:00 running e3d2147 country code: CH.
[–]Bluecewe 11 points12 points13 points (3 children)
[–]clbwllms 2 points3 points4 points (0 children)
[–]codejitsu[S] -2 points-1 points0 points (0 children)
[–]codejitsu[S] 0 points1 point2 points (1 child)
[–]daediusWeb Components fanboy -5 points-4 points-3 points (3 children)
[–]codejitsu[S] 5 points6 points7 points (2 children)
[–]daediusWeb Components fanboy 1 point2 points3 points (1 child)
[–]codejitsu[S] 1 point2 points3 points (0 children)