Lazy-load some Vue components, fix heatmap chunk loading on every page#36719
Merged
wxiaoguang merged 12 commits intogo-gitea:mainfrom Feb 27, 2026
Merged
Lazy-load some Vue components, fix heatmap chunk loading on every page#36719wxiaoguang merged 12 commits intogo-gitea:mainfrom
wxiaoguang merged 12 commits intogo-gitea:mainfrom
Conversation
Defer loading of ActivityHeatmap, PullRequestMergeForm, RepoFileSearch, and ContextPopup Vue components via dynamic import(), reducing the index-domready bundle and deferring vendor chunks like vue3-calendar-heatmap to pages that actually use them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request optimizes bundle size by implementing lazy loading for four Vue components that are safe to load asynchronously without causing visible pop-in effects. The changes move component imports from static to dynamic imports, reducing the main index-domready bundle by approximately 15kB and preventing the large vue3-calendar-heatmap library (260kB) from loading on every page.
Changes:
- Converted four Vue component imports to dynamic lazy-loaded imports using webpack's code-splitting
- Made corresponding functions async to handle dynamic imports
- Components affected: ContextPopup, PullRequestMergeForm, RepoFileSearch, and ActivityHeatmap
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| web_src/js/markup/refissue.ts | Lazy-loads ContextPopup component when showing issue reference tooltips; wraps component mounting in async IIFE within Tippy's onShow callback |
| web_src/js/features/repo-issue-pull.ts | Lazy-loads PullRequestMergeForm component; converts initRepoPullRequestMergeForm to async function |
| web_src/js/features/repo-findfile.ts | Lazy-loads RepoFileSearch component; converts registered init callback to async function |
| web_src/js/features/heatmap.ts | Lazy-loads ActivityHeatmap component inside existing try-catch block; proper error handling already present |
Comments suppressed due to low confidence (1)
web_src/js/features/repo-findfile.ts:80
- The async callback function registered with registerGlobalInitFunc lacks error handling. If the dynamic import fails, the error will be unhandled and could potentially disrupt the page. Consider adding a try-catch block to gracefully handle import failures, similar to the pattern in heatmap.ts (lines 52-55) or file-view.ts (lines 42-46).
registerGlobalInitFunc('initRepoFileSearch', async (el) => {
const {default: RepoFileSearch} = await import(/* webpackChunkName: "RepoFileSearch" */ '../components/RepoFileSearch.vue');
createApp(RepoFileSearch, {
repoLink: el.getAttribute('data-repo-link'),
currentRefNameSubURL: el.getAttribute('data-current-ref-name-sub-url'),
treeListUrl: el.getAttribute('data-tree-list-url'),
noResultsText: el.getAttribute('data-no-results-text'),
placeholder: el.getAttribute('data-placeholder'),
}).mount(el);
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lunny
reviewed
Feb 23, 2026
The merge form is visible on page load for PR pages, so lazy-loading it causes a flash of empty content without a loading indicator. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Renders a static input in the template so there is no pop-in while the Vue component chunk loads asynchronously. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
Author
Reserve min-height on the merge form container to prevent layout shift while the Vue component chunk loads. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reserve min-height on the merge form container to prevent layout shift while the Vue component chunk loads. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
lunny
approved these changes
Feb 26, 2026
Member
Author
wxiaoguang
approved these changes
Feb 27, 2026
silverwind
added a commit
to silverwind/gitea
that referenced
this pull request
Feb 27, 2026
* origin/main: Move Fomantic dropdown CSS to custom module (go-gitea#36530) Use "Enable Gravatar" but not "Disable" (go-gitea#36771) feat: add branch_count to repository API (go-gitea#35351) (go-gitea#36743) Deprecate RenderWithErr (go-gitea#36769) Lazy-load some Vue components, fix heatmap chunk loading on every page (go-gitea#36719) Filter out untracked files from spellchecking (go-gitea#36756) Fix CSS stacking context issue in actions log (go-gitea#36749) Fix milestone/project text overflow in issue sidebar (go-gitea#36741) Update tool dependencies and fix new lint issues (go-gitea#36702) Instance-wide (global) info banner and maintenance mode (go-gitea#36571) Add created_by filter to SearchIssues (go-gitea#36670) Inline and lazy-load EasyMDE CSS, fix border colors (go-gitea#36714) # Conflicts: # templates/repo/issue/view_content/pull_merge_box.tmpl # web_src/js/features/repo-issue-pull.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Lazy-load 3 Vue components that are safe to defer (no pop-in effects). This reduces
index-domreadyfrom 515 KiB to 502 KiB (-2.5%).The old
vue3-calendar-heatmapvendor chunk (264 KiB) that previously loaded on every page is eliminated entirely — it was mostly duplicatetippy.jsandvuecopies that webpack had split out. The actual heatmap library is only ~12 KiB minified, now inlined into theActivityHeatmapasync chunk.