Skip to content

Speed up frontend loading with lazy routes and gzip - #1071

Open
Irozuku wants to merge 15 commits into
developfrom
perf/frontend-performance
Open

Irozuku wants to merge 15 commits into
developfrom
perf/frontend-performance

Conversation

@Irozuku

@Irozuku Irozuku commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Every route downloaded the whole app as one 9.5 MiB script before painting anything (2.9 MiB even gzipped), and the backend sent it uncompressed. Routes, Plotly, non English locales and a few rarely used libraries now load on demand and the backend gzips and caches hashed assets, so the first paint needs 276 KiB of gzipped JavaScript; it also removes duplicate requests, idle job widget rerenders and an object URL leak. On localhost FCP went from 0.81 to 1.82 s down to 0.20 to 0.34 s and LCP from 0.81 to 2.47 s down to 0.24 to 0.94 s; with the Lighthouse desktop preset FCP went from about 8.6 s to 0.78 to 1.09 s and the Home score from 55 to 97.


Type of Change

  • Backend change
  • Frontend change
  • CI / Workflow change
  • Build / Packaging change
  • Bug fix
  • Documentation

Changes (by file)

  • DashAI/front/src/App.jsx: route pages are lazy behind one Suspense; Home stays eager.
  • components/shared/LazyPlot.jsx: new, loads react-plotly.js when the first chart renders.
  • FoldMetricsChart.jsx, LiveMetricsChart.jsx, CorrelationsTab.jsx, NumericTab.jsx, PlotlyJsonVisualizer.jsx, ArtifactRenderer.jsx, PlotActions.jsx, ResultsGraphsPlot.jsx: import LazyPlot under the same Plot name.
  • utils/i18n/index.js, index.jsx, DashAI/front/vite.config.mjs: English stays bundled; each other language is one chunk loaded before the first render and on language change.
  • ExportableCard.jsx, Upload.jsx: html2canvas and jszip are imported inside their handlers.
  • components/tour/TourProvider.jsx, components/updates/UpdatesButton.jsx: Joyride and the updates dialog are lazy.
  • utils/jobPoller.js: one poll at a time, every 10 s in a hidden tab, immediate poll when the tab is visible again.
  • hooks/useJobPolling.js: polls without changes no longer rerender the job widget.
  • hooks/useStrategyKind.js, api/generativeTask.ts: concurrent identical requests for strategy metadata and the generative model list share one request.
  • ToolListItem.jsx, ToolGridItem.jsx: tool thumbnails use loading="lazy".
  • components/shared/FormSchemaFieldCard.jsx: DescriptionBlock is memoized, so typing no longer reparses every field description.
  • components/predictions/InputField.jsx: the image preview object URL is created in an effect and revoked.
  • DashAI/back/api/front_api.py: hashed /assets/ files get immutable cache headers; .js and .css are gzipped once per file version for clients that accept gzip.
  • tests/back/test_main.py: tests for the cache headers and gzip responses.

Testing (optional)

  • Open each module (Home, Data, Models, Generative, Plugins) and check it loads.
  • Open a notebook with an explorer and a run detail: charts render and the chart image download works.
  • Start a training job and check the job queue updates while it runs.
  • Switch the language and reload: the texts follow the selected language.
  • Upload a zip dataset, export a dataset card as image, start a guided tour and open the updates dialog.

Notes (optional)

Chart routes now load Plotly after the first paint, so the chart area is empty for a moment the first time a chart appears. On the first visit to a module the app bar paints a moment before the page.

@Irozuku Irozuku added front Frontend work back Backend work labels Dec 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

back Backend work front Frontend work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant