The goal of the public is not to criticize the
SPA approach, but to show what alternatives there are for implementing an API-based web application. I ask you to discuss only the approach itself, its disadvantages and pros.
I came up with a name for this architectural style - newDHTML. How suitable it is - you can offer another.
So, newDHTML is an architectural style for developing web applications, it is not a framework or library. The idea emerged as an alternative to the SPA for a number of reasons listed below.
Single page application is a good way to organize, but it has the following disadvantages:
')
1. Greatly complicates the front-end part of the application. In addition to html and UI logic, there are also routers, MVC and other sweets.
2. Since the application has one entry point, there is a risk that one error may lead to the non-operational state of the entire application.
3. Duplication of routers (compared to the classical approach)
4. SEO
Idea
MVC logic remains on the server side. The key feature is that the View returns a static page, and the entire dynamic part is collected by the javascript on the client side.
API equivalent of a web application
REST API example:
Resource | Get | POST | PUT | DELETE |
---|
/ books | list of all books | A new book | update all books | deletion of all books |
/ books / 1 | get a book | | book update | book removal |
/ books-index | returns static html page | | | |
Routers with the suffix "-index" return static layout. Then resources are connected on this page (css, js scripts and others). Next, js-components load dynamic data through the REST API and the user sees the final result.
The API is a web application. Once you write an application, you implement the API.
Thus, we have a web application that works entirely through the API, but it is multi-page and is devoid of several SPA disadvantages:
- A simpler architecture, each page can have its own components, its own logic and generally work as a separate module with its own specifics.
- In cases of errors on the front-end - only one page of the set will break down.
- Well, and other advantages, if you notice write.
In the second part I plan to write about the components. In the meantime, thank you all for your attention and good luck!
The idea and text of the author.