[PR #22304] [MERGED] perf(frontend): lazy-load shiki to remove ~5-10MB from initial bundle #26602

Closed
opened 2026-04-20 06:35:53 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22304
Author: @Classic298
Created: 3/6/2026
Status: Merged
Merged: 3/6/2026
Merged by: @tjbck

Base: devHead: perf/lazy-shiki


📝 Commits (1)

  • de3b43e perf(frontend): lazy-load shiki to remove ~5-10MB from initial bundle

📊 Changes

1 file changed (+99 additions, -5 deletions)

View changed files

📝 src/lib/utils/codeHighlight.ts (+99 -5)

📄 Description

codeHighlight.ts had a top-level static import of shiki that pulled the entire highlighter engine (~5-10MB of JavaScript including all language grammars) into any page that imported the module - even if only the lightweight isCodeFile() function was used.

Replace the static shiki import with:

  • A static set of ~85 common language IDs for synchronous extension checks (isCodeFile, extToLang) - no shiki dependency needed
  • A dynamic import('shiki') inside highlightCode(), which is already async so callers are completely unaffected

The static language set covers all commonly-used file extensions. Obscure extensions not in the set simply won't be detected by isCodeFile() (the file still opens fine, just won't show the code file indicator). Highlighting itself still works for all shiki languages since the full bundle loads on demand.

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/22304 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 3/6/2026 **Status:** ✅ Merged **Merged:** 3/6/2026 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `perf/lazy-shiki` --- ### 📝 Commits (1) - [`de3b43e`](https://github.com/open-webui/open-webui/commit/de3b43ef729e962089d26deb738d3dd72ef3d543) perf(frontend): lazy-load shiki to remove ~5-10MB from initial bundle ### 📊 Changes **1 file changed** (+99 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/utils/codeHighlight.ts` (+99 -5) </details> ### 📄 Description codeHighlight.ts had a top-level static import of shiki that pulled the entire highlighter engine (~5-10MB of JavaScript including all language grammars) into any page that imported the module - even if only the lightweight isCodeFile() function was used. Replace the static shiki import with: - A static set of ~85 common language IDs for synchronous extension checks (isCodeFile, extToLang) - no shiki dependency needed - A dynamic import('shiki') inside highlightCode(), which is already async so callers are completely unaffected The static language set covers all commonly-used file extensions. Obscure extensions not in the set simply won't be detected by isCodeFile() (the file still opens fine, just won't show the code file indicator). Highlighting itself still works for all shiki languages since the full bundle loads on demand. ### Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. --> By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 06:35:54 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#26602