ITADN

Re: https://plainvanillaweb.com/blog/articles/2024-09-28-unreasonable-effectiveness-of-vanilla-js/

#7Closedjon49 创建于 2024-10-11
J
jon49commented
Regarding the above post you might like my implementation of something similar that has quite a bit of interactivity but is implemented quite simply. Also, some of your "nice to haves" are implemented in it. All the code is in this page for my vanilla implementation (besides the index.html and css of course): https://github.com/jon49/timer/blob/cca1b8fee0ba4cd2ca7105b36bcf80ec14b22e8d/src/app-vanilla.ts So, it has a nice templating system (createTemplate) and reference gathering system (getXElements). The reference gathering system is based off of [Stage0](https://github.com/Freak613/stage0) but done in a much more naive way which uses significantly less code - if you need higher performance than use something like Stage0. I also handle the events cleanly with data-action attributes and the handleEvent function. Also, using objects and the handleEvent method makes it so when I create event listeners I don't need to clean those event listeners up since when the object (custom element) is destroyed the events are automatically garbage collected. (Thanks to the guy over at https://gomakethings.com/ that blogged about all these things). I tried to keep everything bare metal as possible while still being elegant and easy to use. I like this implementation because I have complete control of updates to the DOM and no weird quirks that frameworks have. I hope this might give you some inspiration and an opportunity to see all the different ways to develop with vanilla JS. I really enjoy reading your blog/website! Let me know if you have any questions or feedback on my implementation.
关闭于 2024-10-19 3 条评论