DEV Community

Discussion on: I Coded My Personal Site With Web Components

Collapse
 
steveblue profile image
Stephen Belovarich • Edited

Looking through your code I think it’s fairly well organized.

One of the biggest pain points for me working with custom elements was event handling. I don’t particularly like calling addEventListener all over the place, which is why I made a Decorator in Readymade that makes for cleaner code. That’s just preference though. It doesn’t hurt to use a library for web components to abstract things like this into a mixin, decorator, or other form of reusable logic. I do like how you’ve gone down a path implementing things from scratch. It means you’ll learn a lot more.

A note about the polyfills: import them from npm packages instead of static code in your repo that way you pick up bugfixes and improvements. Make a polyfill file, import each polyfill from npm packages then load the file in the head of the website.

Collapse
 
raghavmisra profile image
Raghav Misra

Oh, the polyfill predicament. I am using Netlify to host my site and I am unable to access node_modules in my published directory. I was thinking of using cdnjs to serve the polyfill but wasn't sure.

Also, what you said is precisely the reason I reinvented every wheel possible lol. I wanted to learn the internals. Even my crappy SPA router! To alleviate some pain to no frameworks, I wrote some JSX factory function to build DOM nodes. But honestly, something like Readymade, even though it's so small of an abstraction, would ease development a lot.