Skip to content

Self-host ECharts runtime asset - #1284

Merged
miohtama merged 1 commit into
masterfrom
fix/self-host-echarts
Jun 24, 2026
Merged

Self-host ECharts runtime asset#1284
miohtama merged 1 commit into
masterfrom
fix/self-host-echarts

Conversation

@miohtama

Copy link
Copy Markdown
Contributor

Why

ECharts was loaded from jsDelivr at runtime, which makes chart rendering depend on a third-party CDN hostname that may be blocked by Malaysian ISPs or other network filters. Serving the runtime as a first-party build asset keeps the lazy-loading behaviour while making the script available through the normal frontend deployment and Cloudflare proxy.

Lessons learnt

SvelteKit emits ?url package assets under /_app/immutable/assets/ with content-hashed filenames and long-lived immutable cache headers. The built Node adapter returns cache-control: public,max-age=31536000,immutable for the emitted ECharts bundle, so Cloudflare can cache it safely as a first-party static asset.

Summary

  • Add echarts@5.6.0 as a dependency and load echarts/dist/echarts.min.js through Vite instead of jsDelivr.
  • Add resolveEChartsScriptUrl() as the single helper for changing the runtime location later.
  • Reuse the shared ECharts runtime loader from the diagnostics page.
  • Add an integration assertion that the ECharts runtime is same-origin, immutable, and served from /_app/immutable/assets/.
  • Document the first-party ECharts asset and static cache header behaviour.

@miohtama
miohtama merged commit 58b5a78 into master Jun 24, 2026
5 checks passed
@miohtama
miohtama deleted the fix/self-host-echarts branch June 24, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant