DEV Community

Atul Sharma
Atul Sharma

Posted on

Why it's so hard to write a single page application(SPA) with just vanilla JavaScript?

Front-end web applications are all about
-> Handling data + displaying data in a user interface.
-> User interface needs to stay in sync with data

Building a complex frontend with vanilla javascript alone requires a large amount of direct DOM manipulation and traversing .

1.Our code would be extremely complex and really hard to understand and we will probably just end up with a huge mess of entangled spaghetti code.
2.Typically in vanilla javascript apps state such as simple text or numbers are oftentimes simply stored right in the DOM. So right in the HTML elements itself rather than in a central place in the application.

The result is that we end up with many parts of the app accessing and changing that Dom state directly, which makes the spaghetti code even harder to understand and it will most certainly introduce many bugs into our application.

So basically frameworks like Angular, React or Vue take this hard work of synchronizing data with the user interface away from developers.
Source

Top comments (0)