From 7303e4d59280f76fa4bf4592087e8507e067c406 Mon Sep 17 00:00:00 2001 From: Oliver Giles Date: Sat, 22 Jan 2022 20:08:23 +1300 Subject: [PATCH] fe perf: insertAdjacentHTML is faster than innerHTML+= --- src/resources/js/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/resources/js/app.js b/src/resources/js/app.js index 124b81b..fff0e0d 100644 --- a/src/resources/js/app.js +++ b/src/resources/js/app.js @@ -667,14 +667,14 @@ const Run = templateId => { // a callback interface for handling unknown sequences. // Also, update the DOM directly rather than using a binding through // Vue, the performance is noticeably better with large logs. - target.innerHTML += ansi_up.ansi_to_html( + target.insertAdjacentHTML('beforeend', ansi_up.ansi_to_html( logToRender.replace(/\033\[\{([^:]+):(\d+)\033\\/g, (m, $1, $2) => '~~~~LAMINAR_RUN~'+$1+':'+$2+'~' ) ).replace(/~~~~LAMINAR_RUN~([^:]+):(\d+)~/g, (m, $1, $2) => ''+$1+':'+ '#'+$2+'' - ); + )); logToRender = ''; if (logComplete) { // output finished