Slightly defer the initialization but not loading of CKEditor
authorAlexander Ebert <ebert@woltlab.com>
Wed, 26 Jul 2023 15:50:10 +0000 (17:50 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 26 Jul 2023 15:50:10 +0000 (17:50 +0200)
This change improves the perceived performance by forcing the browser to insert a rendering pass before initializing the browser. In particular on mobile devices this creates an opportunity to refresh the screen.

ts/WoltLabSuite/Core/Component/Ckeditor.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor.js

index 3b78670556aab203d7a73e6cfb6d769aee50b1e2..54dbf90a6117dd36590c9cd2bffd16c35d143e4d 100644 (file)
@@ -220,6 +220,10 @@ export async function setupCkeditor(
 
   await import("ckeditor5-bundle");
 
+  await new Promise((resolve) => {
+    window.requestAnimationFrame(resolve);
+  });
+
   initializeFeatures(element, features);
 
   if (features.attachment) {
index feb28bb662c9c167e04f729afb3b8f0329f5ae2f..98de8ccdcadae677726d54d99389be1591ea3ffe 100644 (file)
@@ -156,6 +156,9 @@ define(["require", "exports", "tslib", "./Ckeditor/Attachment", "./Ckeditor/Medi
             throw new TypeError(`Cannot initialize the editor for '${element.id}' twice.`);
         }
         await new Promise((resolve_1, reject_1) => { require(["ckeditor5-bundle"], resolve_1, reject_1); }).then(tslib_1.__importStar);
+        await new Promise((resolve) => {
+            window.requestAnimationFrame(resolve);
+        });
         initializeFeatures(element, features);
         if (features.attachment) {
             (0, Attachment_1.setup)(element);