Code Monkey home page Code Monkey logo

todomvc-vanillajs-2022's Introduction

TodoMVC App Written in Vanilla JS in 2022

It seems straightforward to build reasonably complex things using only modern JavaScript these days! We can take advantage of most newer features without hacks or polyfills.

Here's my Vanilla JavaScript implementation:

  • ~200 lines of code total (compared to the official vanilla JS TodoMVC from 6 years ago was 900+ LOC)
  • No build tools
  • JavaScript modules

View the working example on GitHub pages

Criticism, PRs, and feedback are welcome!

Project Blog Post:

Modern Vanilla JavaScript TodoMVC in 2022 Article

Additional Examples

Initial Code

The initial version came together in only 60 minutes, then ~30 min of refactoring: see the commit here

How quick it was to get working was what initially got me pumped about all of the progress in the core JavaScript language.

App Architecture

People were concerned about the scalability of apps like this since there are no components, and it's all one App. So I extracted the TodoList and App components and wired the components together on the app-architecture branch.

Branch: https://github.com/1Marc/todomvc-vanillajs-2022/tree/app-architecture

Note: I realize it is silly to say the word "scalable" in the context of a todo app, but this should be looked at as a blueprint for building something more extensive. I plan to make more ambitious examples in the future to show what's possible.

More Granular & Performant DOM Updates for Large Lists

Since I'm rendering everything on every update of the model from scratch, this can cause performance issues on long lists.

Here's a branch sending specific events with context from the model so we can make DOM updates more selectively as we need them (see code diff).

Branch: https://github.com/1Marc/todomvc-vanillajs-2022/tree/performant-rendering

More Performant DOM Updates for Large Lists with lit-html (Plus animations!)

We can achieve the same performant DOM updates with far less code by adopting lit-html using the repeat directive (see code diff).

Branch: https://github.com/1Marc/todomvc-vanillajs-2022/tree/animation-lithtml

Example UI Components Using this Architecture

Vanilla JavaScript View Switcher Based on Hash Change

Vanilla JavaScript Countdown Clock

License

Creative Commons License
This work by TasteJS is licensed under a Creative Commons Attribution 4.0 International License.

todomvc-vanillajs-2022's People

Contributors

1marc avatar jonathantneal avatar julienetie avatar k3arn3y avatar kenearley avatar lesleh avatar matuzo avatar nyakotey avatar tbranyen avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.