News for hackers. Stuff that matters.
Re:Virtual DOM is pure overhead (2018) by chriswarbo on Tuesday May 21, 2019 @05:04AM (#19968577)
I get what you're saying, but anecodtally I can say I've never worked on a codebase like that. The pattern I came across most frequently would use JS values to store state, scoped as tightly to the relevant event handler as possible, e.g.

    $(function(){
      var myState = 123;
      var myElem  = $('<span>' + myState + '</span>');
      $('#myParent').append(
        myElem,
        $('<button text="Increment" />').click(function(){
          myState = myState + 1;
          myElem.text(myState + '');
        }));
    });
Interaction with the DOM was treated as I/O, akin to file or stdio access: for reading, get it into a sensible internal variable as soon as possible; for writing, dump it out as the final step. Using the DOM to hold state seems, to me, akin to holding state in an external file (reading and writing as needed), rather than a variable.

There are no comments on this comment yet.