Skip to content

Lazy-load some Vue components, fix heatmap chunk loading on every page#36719

Merged
wxiaoguang merged 12 commits intogo-gitea:mainfrom
silverwind:lazyvue
Feb 27, 2026
Merged

Lazy-load some Vue components, fix heatmap chunk loading on every page#36719
wxiaoguang merged 12 commits intogo-gitea:mainfrom
silverwind:lazyvue

Conversation

@silverwind
Copy link
Copy Markdown
Member

@silverwind silverwind commented Feb 23, 2026

Lazy-load 3 Vue components that are safe to defer (no pop-in effects). This reduces index-domready from 515 KiB to 502 KiB (-2.5%).

The old vue3-calendar-heatmap vendor chunk (264 KiB) that previously loaded on every page is eliminated entirely — it was mostly duplicate tippy.js and vue copies that webpack had split out. The actual heatmap library is only ~12 KiB minified, now inlined into the ActivityHeatmap async chunk.

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>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 23, 2026
@silverwind silverwind added performance/speed performance issues with slow downs and removed modifies/frontend labels Feb 23, 2026
@silverwind silverwind changed the title Lazy-load Vue components to reduce main bundle size Lazy-load some Vue components Feb 23, 2026
@silverwind silverwind requested a review from Copilot February 23, 2026 04:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@silverwind silverwind changed the title Lazy-load some Vue components Lazy-load some Vue components, fix heatmap chunk loading on every page Feb 23, 2026
@silverwind silverwind marked this pull request as draft February 23, 2026 07:49
silverwind and others added 2 commits February 24, 2026 03:09
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>
@github-actions github-actions bot added the modifies/templates This PR modifies the template files label Feb 24, 2026
@silverwind
Copy link
Copy Markdown
Member Author

silverwind commented Feb 24, 2026

I've added a placeholder element for the rending of RepoFileSearch, so the pop-in effect is no longer visible on the repo page because it visually renders the same before and after JS loads.

image

ContextPopup and ActivityHeatmap and have no pop-in problems, so they are fine to lazy-load always.

PullRequestMergeForm now also has a space-reserving div added to avoid the vertical layout shift.

@silverwind silverwind marked this pull request as ready for review February 24, 2026 02:18
silverwind and others added 4 commits February 24, 2026 03:24
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>
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 26, 2026
@lunny lunny added this to the 1.26.0 milestone Feb 26, 2026
@silverwind
Copy link
Copy Markdown
Member Author

Updated the placeholder so this "T" does not pop in on page load.

image

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 27, 2026
@wxiaoguang wxiaoguang enabled auto-merge (squash) February 27, 2026 04:38
@wxiaoguang wxiaoguang merged commit 72e63ee into go-gitea:main Feb 27, 2026
26 checks passed
@wxiaoguang wxiaoguang deleted the lazyvue branch February 27, 2026 05:06
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/frontend modifies/templates This PR modifies the template files performance/speed performance issues with slow downs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants