Message from JavaScript discussions
March 2017
— If reading the docs doesn't teach you, then you need to learn how to read docs, which isn't really a snarky comment but a reality
Performance us everything when it comes to the server-side.... don't let some blogger get into your head
— Na, In complex applications say using some back-end MVC framework, it is easy to include html markup in server side templates rather than jsx
— Server rendered apps for example
— Not everyone has a balls deep 100% client rendered js spa
— But if you do... use document fragments
— It is not only a matter of preference rather it mostly depends upon what are the requirements
— Each page of the app should be in it's own persistent document fragment, then you can change it, then clone it into a DOM node and bam, that is the fastest possible way to interact with the page in js
—
var myPage = document.createDocumentFragment();
var myContainer = myPage.createElement("div");
myContainer.appendChild("Hello!");
this creates a blazing fast docfrag that doesn't exist in the DOM, it gets changed extremely quickly, except this can be very cumbersome to write yourself so I reccomend a premade lib or framework to take some of the load off
— That is a virtual DOM by definition
— No react required
— A docfrag is literally the same principles as react's virtual dom, even