DEV Community

Discussion on: Building a Single Page App without frameworks 🔥

Collapse
 
fagnerbrack profile image
Fagner Brack • Edited

Basically if you remove the javascript code and get the html fragment from the server using the "get html" function then everything still works.

Progressive enhancement at its best.

This is a proof that you don't need a front end framework to build an spa that can track states through the Url using the history API. No state on client side therefore no need for a "setState all the things".

Great post, rare to see such quality around the Web these days.

Collapse
 
catinhocr profile image
Cato

is that a node.js function? cant find any reference to it after a couple google hits

Collapse
 
fagnerbrack profile image
Fagner Brack • Edited

It's a reference to the code examples in the original post. There's a custom "getHtml()" function there.

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
fagnerbrack profile image
Fagner Brack • Edited

[...] you want to write your front-end code all in a separate project and keep your back-end unaware of it

Why? They are still coupled but now with a weak layer between them with a home-made protocol to interpret the response body. Views should still be sent from the back-end systems unless your business logic is in your front-end code and back-end has no business logic. If that's the case you have a service that returns data, and that's called a database. If that's the case then well... use a database query language not HTTP.

HTTP is for hypertext/hypermedia state transfer, use the tools for what they're optimised for, don't try to repurpose them to something that makes absolutely no sense.