Skip to content

Asset Management

LiveCharts ships pre-built IIFE bundles for every supported engine and plugin. The @liveChartsScripts directive resolves these against the configured asset mode.

Place @liveChartsScripts before @livewireScripts and before the closing </body> tag. The directive registers the livecharts Alpine data factory; Livewire’s @livewireScripts bootstraps Alpine — so the factory must exist before Alpine initializes.

<body>
<!-- chart components here -->
@liveChartsScripts
@livewireScripts
</body>

If your layout uses additional script directives (e.g. @fluxScripts), place @liveChartsScripts first:

@liveChartsScripts
@fluxScripts
@livewireScripts

Using a Blade layout (@extends/@section)? You can place the directive in the layout’s <head>. The directive uses Blade’s push/stack mechanism: chart components push their engine script tags when they render, and the stack is flushed wherever @liveChartsScripts is placed. Because @extends child views render before the layout resolves its stacks, <head> placement works correctly in this pattern.

layouts/app.blade.php
<head>
@liveChartsScripts {{-- works here with @extends/@section --}}
</head>
FileSource
resources/dist/livecharts.jsCore runtime (Alpine integration).
resources/dist/apexcharts.jsApexCharts ^5.10.6 IIFE bundle.
resources/dist/chartjs.jsChart.js ^4.5.1 IIFE bundle (mirrors UMD named exports on window.Chart).
resources/dist/chartjs-treemap.jschartjs-chart-treemap plugin.
resources/dist/chartjs-matrix.jschartjs-chart-matrix plugin.
resources/dist/chartjs-sankey.jschartjs-chart-sankey plugin.
resources/dist/chartjs-financial.jschartjs-chart-financial plugin (candlestick, OHLC).
resources/dist/luxon.jsLuxon date library.
resources/dist/chartjs-adapter-luxon.jsChart.js time-axis adapter.

livecharts:install publishes all bundles to public/vendor/livecharts/.

Configure via LIVECHARTS_ASSETS_MODE:

ModeBehaviour
localServe only the local copies. Fails closed if the file is missing. Requires published assets.
cdnServe only the public CDN URLs. No local files needed.
bothServe local first, fall back to CDN via <script> onerror handler. Default. Requires published assets.

If you fork the package or override package.json deps, rebuild from source:

Terminal window
npm install
npm run build

The Vite config is mode-driven. Each target (livecharts, apexcharts, chartjs) emits an IIFE bundle that externalizes its peer (e.g. chart.js for plugins, luxon for the adapter) so plugins resolve against the global Chart set up by the core shim.

Plugin bundles import named exports from chart.js at runtime. The Chart.js shim in resources/dist/chartjs.js mirrors every named export onto window.Chart so plugin bundles resolve correctly. The ChartJsAdapter registers the engine asset before any plugin asset to guarantee load ordering.

You don’t have to think about any of this — but if you’re auditing the script tags rendered by @liveChartsScripts, that’s why they appear in that order.

The js-build.yml workflow runs npm ci && npm run build and fails the PR if the committed resources/dist directory drifts out of sync with the source. This guarantees a fresh checkout always produces deterministic artefacts.