Load JavaScript and CSS assets from Neos/Flow packages via Fusion.
Carbon.FileLoader supports two strategies:
tags: render<script>/<link>tags directly in markup.attributes: renderdata-*attributes and load assets with the includedLoader.js.
Install the package via Composer:
composer require carbon/fileloaderFusion auto-include and the Eel helper context are registered automatically via package settings.
Carbon:
FileLoader:
strategy: tags
hashLength: 8
debug: false
removeLocalhost: truestrategy:tagsorattributes.hashLength: length of the cache-busting hash (h=...) appended to generated file URLs. Set0,falseornullto disable.debug: enables verbose browser console output for theattributesstrategy.removeLocalhost: rewriteshttp://localhost/...andhttps://localhost/...to/....
Use the high-level component:
assets = Carbon.FileLoader:Component {
package = 'Vendor.Site'
css = 'Main.css'
js = 'App.js'
mjs = 'Hydration.js'
}
strategy:tagsorattributes(defaults toCarbon.FileLoader.strategy).inline: inline content instead of external URLs. Forcestagsstrategy.package: package key (required unless absolute/resource URL is provided in filenames).js,css,mjs: string, comma-separated string, or array.neverIncludeJS,neverIncludeCSS,neverIncludeMJS: disable one asset type.jsFolder,cssFolder,mjsFolder: relative folder inPublic/.scriptExecution:defer,async, ornull.eventOnLoad: custom event name (attributes strategy only).useCache: loader cache for runtime loading (attributes strategy only).debug: runtime console debug output (attributes strategy only).slipstream,slipstreamPrepend: optional Sitegeist.Slipstream integration (tags strategy).
Renders final HTML tags directly.
assets = Carbon.FileLoader:Strategy.Tags {
package = 'Vendor.Site'
css = ['Main.css', 'Print.css']
js = ['Vendor.js', 'App.js']
mjs = 'Hydration.js'
scriptExecution = 'defer'
}
Use this strategy if you want classic server-rendered asset tags.
Renders data-* attributes that are interpreted by Loader.js in the browser.
assets = Carbon.FileLoader:Strategy.Attributes {
package = 'Vendor.Site'
css = 'Main.css'
js = 'App.js'
mjs = 'Hydration.js'
scriptExecution = 'defer'
eventOnLoad = 'assets:loaded'
useCache = true
}
When using this strategy, include and execute the client-side loader:
<script type="module">
import { initLoader } from "/_Resources/Static/Packages/Carbon.FileLoader/Modules/Loader.min.js";
initLoader();
</script>You can call initLoader({ rootElement }) again after replacing or appending dynamic markup.
Resolve one file:
singleFile = Carbon.FileLoader:Helper.File {
package = 'Vendor.Site'
folder = 'Scripts/'
file = 'App.js'
}
Resolve multiple files:
multipleFiles = Carbon.FileLoader:Helper.FileItems {
package = 'Vendor.Site'
folder = 'Styles/'
items = ['Main.css', 'Print.css']
}
Registered in Fusion default context as Carbon.FileLoader.
filter(value): normalize string/array input into a cleaned array.uri(uri, inline = false, package = null, folder = null, hashLength = null): resolve one URL or inline content.uris(arrayOrString): resolve many URLs and join them with commas.encodeUrl(string): Base64 URL-safe encoding (used by attributes strategy).
- If
filecontains//(for examplehttps://...orresource://...), it is used as-is. - Otherwise, the file is resolved via:
resource://<Package>/Public/<Folder><File>
- For external files, only URL generation is used.
- For inline mode, file content is loaded directly.
The package ships ready-to-use browser modules in Resources/Public/Modules/:
Loader.js/Loader.min.jsEventDispatcher.js/EventDispatcher.min.jsEventListener.js/EventListener.min.js
Install dependencies:
pnpm installBuild assets:
pnpm buildWatch mode:
pnpm watchAlternative via Makefile:
make production