prepend new elements instead of replacing HTML on AJAX update (#9) (#12)

Replacing the body by prepending HTML results in the full content
being re-rendered. This can be a performance issue, but is definitely
annoying when embedding media in ticks.
This commit is contained in:
2020-05-01 14:52:25 +02:00
committed by GitHub
parent ee60444932
commit 6ed625dab2
2 changed files with 10 additions and 2 deletions

View File

@ -164,8 +164,15 @@
* @return {void}
*/
var updateHTML = function( t, u ) {
// Prepend HTML of new ticks.
t.e.innerHTML = u.h + t.e.innerHTML;
// Parse new DOM-part.
var n = document.createElement( 'ul' );
n.innerHTML = u.h;
// Prepend new ticks to container.
while ( n.hasChildNodes() ) {
t.e.prepend( n.lastChild );
}
t.e.parentNode.setAttribute( 'data-sclt-last', u.t );
// Remove tail, if limit is set.