From feb8c180d54ab5b3d887f5a5d785e27d8ab245fc Mon Sep 17 00:00:00 2001 From: manager Date: Thu, 15 Oct 2026 21:06:06 +0000 Subject: [PATCH 1/2] perf(uxcg): stop shipping unused data on UXCG pages The question page carried every locale's questions three times and every locale's biases (3.1 MB of page data); the list page carried all biases it never renders (1.7 MB). Drop the unused props, send biases for the current locale only, and slim the other locales' questions to the fields search reads. Measured on the live payloads: 3.14 MB -> 0.74 MB and 1.73 MB -> 0.33 MB. Co-Authored-By: Claude Opus 5.5 --- src/pages/uxcg/[slug].tsx | 7 +++---- src/pages/uxcg/index.tsx | 35 +++++++++++------------------------ src/uxcore/lib/helpers.ts | 21 +++++++++++++++++++++ 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/pages/uxcg/[slug].tsx b/src/pages/uxcg/[slug].tsx index 0b6ec79e..7e03ca6c 100644 --- a/src/pages/uxcg/[slug].tsx +++ b/src/pages/uxcg/[slug].tsx @@ -11,6 +11,7 @@ import { generateQuestionsSeo, getAdjacentUXCGTitles, mergeQuestionsLocalization, + slimUXCGQuestions, } from '@uxcore/lib/helpers'; import { getUXCGSlugPaths } from '@uxcore/lib/paths'; import { @@ -289,17 +290,15 @@ export const getStaticProps: GetStaticProps = async ({ params, locale }) => { currentSlug: slug, languageSwitchSlugs, tags, - questionsTest: questions, questionsSeo, title: question?.attributes?.title || '', mainSeo, modalData: uxcgData || null, answerRelatedQuestions: answerRelatedQuestions || null, questionsLength: sortedQuestions?.length, - questions: sortedQuestions, - allQuestions: questions, + allQuestions: slimUXCGQuestions(questions, locale), id: question?.attributes.number || null, - biases, + biases: { [locale]: biases[locale as 'en' | 'ru' | 'hy'] }, }, revalidate: 5, }; diff --git a/src/pages/uxcg/index.tsx b/src/pages/uxcg/index.tsx index 22132d9d..c07e62d6 100644 --- a/src/pages/uxcg/index.tsx +++ b/src/pages/uxcg/index.tsx @@ -1,25 +1,19 @@ -import { GetStaticProps } from 'next'; -import { useRouter } from 'next/router'; -import React, { FC, useMemo, useState } from 'react'; - -import { QuestionType, TagType } from '@uxcore/local-types/data'; -import { TRouter } from '@uxcore/local-types/global'; - -import { - generateQuestionsSeo, - mergeBiasesLocalization, - mergeQuestionsLocalization, -} from '@uxcore/lib/helpers'; - -import { getStrapiBiases } from '@uxcore/api/biases'; import { getUXCGSeo } from '@uxcore/api/mainPageSeo'; import { getStrapiQuestions } from '@uxcore/api/questions'; import { getTags } from '@uxcore/api/tags'; - import SeoGenerator from '@uxcore/components/SeoGenerator'; import Spinner from '@uxcore/components/Spinner'; - import UXCGLayout from '@uxcore/layouts/UXCGLayout'; +import { + generateQuestionsSeo, + mergeQuestionsLocalization, + slimUXCGQuestions, +} from '@uxcore/lib/helpers'; +import { QuestionType, TagType } from '@uxcore/local-types/data'; +import { TRouter } from '@uxcore/local-types/global'; +import { GetStaticProps } from 'next'; +import { useRouter } from 'next/router'; +import React, { FC, useMemo, useState } from 'react'; interface UxcgProps { tags: TagType[]; @@ -72,12 +66,6 @@ export default Index; export const getStaticProps: GetStaticProps = async ({ locale }) => { const tags = getTags(); const questions = await getStrapiQuestions(); - const biases = await getStrapiBiases(); - const sortedBiases = mergeBiasesLocalization( - biases.en, - biases.ru, - biases.hy, - ).sort((a, b) => a.number - b.number); // HYTranslation TODO const sortedQuestions = mergeQuestionsLocalization( questions.en, @@ -91,11 +79,10 @@ export const getStaticProps: GetStaticProps = async ({ locale }) => { return { props: { - biases: sortedBiases, tags, questionsSeo, mainSeo, - allQuestions: questions, + allQuestions: slimUXCGQuestions(questions, locale), }, revalidate: 5, }; diff --git a/src/uxcore/lib/helpers.ts b/src/uxcore/lib/helpers.ts index 34f05658..4cfa3b1d 100644 --- a/src/uxcore/lib/helpers.ts +++ b/src/uxcore/lib/helpers.ts @@ -525,3 +525,24 @@ export const getAdjacentUXCGTitles = (locale, uxcgDats, activeQuestion) => { next: nextQuestion ? `${nextQuestion.slug}` : null, }; }; + +// UXCG pages ship every locale's questions so search can match aliases in any +// language. Only the current locale is rendered; the others keep the fields +// search reads, which cuts each page's data by several hundred KB. +export const slimUXCGQuestions = ( + questions: Record<'en' | 'ru' | 'hy', any[]>, + locale: string, +) => + Object.fromEntries( + Object.entries(questions).map(([key, list]) => [ + key, + key === locale + ? list + : (list || []).map(({ attributes }) => ({ + attributes: { + number: attributes?.number ?? null, + aliases: attributes?.aliases ?? null, + }, + })), + ]), + ); From 995203d590f0a2e4de146ccfafa0e4a8a41ece2d Mon Sep 17 00:00:00 2001 From: manager Date: Thu, 15 Oct 2026 21:09:24 +0000 Subject: [PATCH 2/2] fix(uxcg): fall back to an empty bias list for an unknown locale Co-Authored-By: Claude Opus 5.5 --- src/pages/uxcg/[slug].tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/uxcg/[slug].tsx b/src/pages/uxcg/[slug].tsx index 7e03ca6c..9a9856ae 100644 --- a/src/pages/uxcg/[slug].tsx +++ b/src/pages/uxcg/[slug].tsx @@ -298,7 +298,7 @@ export const getStaticProps: GetStaticProps = async ({ params, locale }) => { questionsLength: sortedQuestions?.length, allQuestions: slimUXCGQuestions(questions, locale), id: question?.attributes.number || null, - biases: { [locale]: biases[locale as 'en' | 'ru' | 'hy'] }, + biases: { [locale]: biases[locale as 'en' | 'ru' | 'hy'] ?? [] }, }, revalidate: 5, };