3 ms·
You can, using the template element: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template https://developer.mozilla.org/en-US/docs/Web/HTML/Elemen
by eeJah9to 6y ago
You can, using the template element: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template https://developer.mozilla.org/en-US/docs/Web/HTML/Element/te...
I tried that for webcomponents, but I found more to my taste to actually have everything in my javascript file rather than to jump between files (it's not that messy if you keep your components smalls).
- clairity 6y agoneat, i remember running across that a while back, but promptly forgot about it. thanks for the reminder!
- Izkata 6y agoI experimented with this some years ago, building my own mini-framework for components. The main system provided a global hook that javascript within the template file could attach itself to, so everything for a single component did exist in a single file. So it is doable. (I liked that part of my system, but I'd rewrite about half of it if I wanted to use it again)