Improve load time with a single write to innerHTML instead of one for every entry.

This commit is contained in:
kor 2018-10-30 21:09:48 +13:00
parent 83f54dc2db
commit 5128929933
2 changed files with 15 additions and 8 deletions

View File

@ -4067,4 +4067,11 @@ ORKL
AUTH : kodedninja AUTH : kodedninja
LINK : https://github.com/kodedninja/orkl LINK : https://github.com/kodedninja/orkl
NOTE : reference for memex loading (spinner) NOTE : reference for memex loading (spinner)
TAGS : p2p, dat, blog TAGS : p2p, dat, blog
WITH LOVE FROM VERY SMALL PLACES
DATE : 12018-10-30
TYPE : music
AUTH : kodedninja
TAGS : ambient, calm
LINK : https://0x22.bandcamp.com/album/with-love-from-very-small-places

View File

@ -58,14 +58,15 @@ function View()
} }
// BUILD // BUILD
this.grid.innerHTML = ''; let dbKeys = Object.keys(db);
var dbKeys = Object.keys(db); let i = 0;
var i = 0; let contentHtml = '';
while (i < dbKeys.length) while (i < dbKeys.length)
{ {
this.buildEntry(db, dbKeys[i]); contentHtml += this.buildEntry(db, dbKeys[i]);
i++; i++;
} }
this.grid.innerHTML = contentHtml;
// LAYOUT // LAYOUT
if (SETTINGS.USEMASONRY) if (SETTINGS.USEMASONRY)
@ -74,7 +75,7 @@ function View()
this.msnry.layout(); this.msnry.layout();
} }
var imgLoad = imagesLoaded( container ); let imgLoad = imagesLoaded( container );
// When all images finish: redo mansonry layout // When all images finish: redo mansonry layout
imgLoad.on( 'always', function() { parent.msnry.layout(); } ); imgLoad.on( 'always', function() { parent.msnry.layout(); } );
} }
@ -324,8 +325,7 @@ function View()
} }
entry += `</div>`; entry += `</div>`;
return entry;
this.grid.innerHTML += entry;
} }
this.doTypeIcon = function(type, count) this.doTypeIcon = function(type, count)