Message from JavaScript discussions

March 2017

— Performance us everything when it comes to the server-side.... don't let some blogger get into your head

Message permanent page


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

Message permanent page


var myPage = document.createDocumentFragment();
var myContainer = myPage.createElement("div");

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

Message permanent page

— That is a virtual DOM by definition

— No react required

— A docfrag is literally the same principles as react's virtual dom, even

— I'll try to explain with situations which I face daily, we use Symfony in our company and we have created custom form types in Symfony using Twig and AngularJS, these form types are basically reusable components which do a lot of work from helping in generation of views to ajax requests. We just write one line of code to do all this stuff.

Message permanent page