{"action":"created","issue":{"url":"https://api.github.com/repos/tbranyen/diffhtml/issues/7","labels_url":"https://api.github.com/repos/tbranyen/diffhtml/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/tbranyen/diffhtml/issues/7/comments","events_url":"https://api.github.com/repos/tbranyen/diffhtml/issues/7/events","html_url":"https://github.com/tbranyen/diffhtml/issues/7","id":71907345,"number":7,"title":"Allow using buffers + extra thoughts","user":{"login":"nfroidure","id":229633,"avatar_url":"https://avatars.githubusercontent.com/u/229633?v=3","gravatar_id":"","url":"https://api.github.com/users/nfroidure","html_url":"https://github.com/nfroidure","followers_url":"https://api.github.com/users/nfroidure/followers","following_url":"https://api.github.com/users/nfroidure/following{/other_user}","gists_url":"https://api.github.com/users/nfroidure/gists{/gist_id}","starred_url":"https://api.github.com/users/nfroidure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nfroidure/subscriptions","organizations_url":"https://api.github.com/users/nfroidure/orgs","repos_url":"https://api.github.com/users/nfroidure/repos","events_url":"https://api.github.com/users/nfroidure/events{/privacy}","received_events_url":"https://api.github.com/users/nfroidure/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-04-29T15:25:58Z","updated_at":"2015-05-27T22:49:23Z","closed_at":null,"body":"After having a look at React i also thought that something like an 'upsertHTML' would be far better and i'm really happy to see things moving that way.\r\n\r\nOne reason why i think the diffHTML approach is better is that building a string containing HTML and let browsers make the diff allows to avoid garbage collection cycles.\r\n\r\nI think an optimal way to build that string would be to user buffers. Since the HTML contents of an application rarely vary in size, we could avoid garbage collection and have really impressive performances.\r\n\r\nAnother great thing with ArrayBuffers is that they are \"transferable objects\" https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers#Passing_data_by_transferring_ownership_(transferable_objects)\r\n\r\nIt means you can:\r\n- compute the UI into a WebWorker and fill an ArrayBuffer with the new HTML\r\n- transfer it to the main thread and render changes to the DOM.\r\n\r\nUsing 2 buffers, you could perform the HTML diff from the first while the next HTML to render would compute in the web worker to fill the second buffer. At each rendering cycle, you would just have to exchange buffers and render/compute again.\r\n\r\nThat's why i think diffHTML should accept array buffers containing encoded strings.\r\n\r\nI assume you used virtual-dom to provide a quick implementation but i think that in the end, an HTML parser combined to a tree walker applying changes on the fly would be a better fit for implementing diffHTML.\r\n\r\nHope it helps."},"comment":{"url":"https://api.github.com/repos/tbranyen/diffhtml/issues/comments/106102091","html_url":"https://github.com/tbranyen/diffhtml/issues/7#issuecomment-106102091","issue_url":"https://api.github.com/repos/tbranyen/diffhtml/issues/7","id":106102091,"user":{"login":"tbranyen","id":181635,"avatar_url":"https://avatars.githubusercontent.com/u/181635?v=3","gravatar_id":"","url":"https://api.github.com/users/tbranyen","html_url":"https://github.com/tbranyen","followers_url":"https://api.github.com/users/tbranyen/followers","following_url":"https://api.github.com/users/tbranyen/following{/other_user}","gists_url":"https://api.github.com/users/tbranyen/gists{/gist_id}","starred_url":"https://api.github.com/users/tbranyen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbranyen/subscriptions","organizations_url":"https://api.github.com/users/tbranyen/orgs","repos_url":"https://api.github.com/users/tbranyen/repos","events_url":"https://api.github.com/users/tbranyen/events{/privacy}","received_events_url":"https://api.github.com/users/tbranyen/received_events","type":"User","site_admin":false},"created_at":"2015-05-27T22:49:23Z","updated_at":"2015-05-27T22:49:23Z","body":"Not sure if a DOM pool is really needed anymore.  We aren't creating excessive elements.  Going to punt on that for now."}}