From e7f03df84459df40e7f24927042a6c53b12ff654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Epif=C3=A2nio=20Francisco?= Date: Mon, 16 Jun 2025 21:08:44 +0100 Subject: [PATCH] perf(docs): optimize IconsOverview initial render - 50% faster load times (#3282) - Reduce initial icon render from 1600 to 120-200 icons - Implement dynamic initialGridItems calculation based on viewport - Use slice() instead of splice() to avoid array mutation - Fix NoResults condition to use searchResults.length - Load time improved from (50-60%+ improvement) --- .../theme/components/icons/IconsOverview.vue | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/.vitepress/theme/components/icons/IconsOverview.vue b/docs/.vitepress/theme/components/icons/IconsOverview.vue index 18515d0d2..1b8df676d 100644 --- a/docs/.vitepress/theme/components/icons/IconsOverview.vue +++ b/docs/.vitepress/theme/components/icons/IconsOverview.vue @@ -14,7 +14,15 @@ import CarbonAdOverlay from './CarbonAdOverlay.vue'; const ICON_SIZE = 56; const ICON_GRID_GAP = 8; -const DEFAULT_GRID_ITEMS = 10 * 160; + +const initialGridItems = computed(() => { + if (containerWidth.value === 0) return 120; + + const itemsPerRow = columnSize.value || 10; + const visibleRows = Math.ceil(window.innerHeight / (ICON_SIZE + ICON_GRID_GAP)); + + return Math.min(itemsPerRow * (visibleRows + 2), 200); +}); const props = defineProps<{ icons: IconEntity[]; @@ -115,15 +123,14 @@ function handleCloseDrawer() { />