© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•7mo ago•
9 replies
Matthew

loadedOnRequest() not loading assets on request

I register the followinf assets in my service provider:
FilamentAsset::register([
    Js::make('local-player-script', __DIR__ . '/../../resources/js/local-player.js')->loadedOnRequest(),
    Js::make('radio-player-script', __DIR__ . '/../../resources/js/radio-player.js')->loadedOnRequest(),
    Css::make('player-stylesheet', __DIR__ . '/../../resources/css/player.css')->loadedOnRequest(),
]);
FilamentAsset::register([
    Js::make('local-player-script', __DIR__ . '/../../resources/js/local-player.js')->loadedOnRequest(),
    Js::make('radio-player-script', __DIR__ . '/../../resources/js/radio-player.js')->loadedOnRequest(),
    Css::make('player-stylesheet', __DIR__ . '/../../resources/css/player.css')->loadedOnRequest(),
]);


I have a custom widget the needs one of the JS files. But they arent loaded when requested!
widget:
<x-filament-widgets::widget>
    <div
        x-data="radioPlayerCode"
        x-load-js="[@js(\Filament\Support\Facades\FilamentAsset::getScriptSrc('radio-player-script'))]"
        x-load-css="[@js(\Filament\Support\Facades\FilamentAsset::getStyleHref('player-stylesheet'))]"
    >
       <!-- ... -->
    </div>
</x-filament-widgets::widget>
<x-filament-widgets::widget>
    <div
        x-data="radioPlayerCode"
        x-load-js="[@js(\Filament\Support\Facades\FilamentAsset::getScriptSrc('radio-player-script'))]"
        x-load-css="[@js(\Filament\Support\Facades\FilamentAsset::getStyleHref('player-stylesheet'))]"
    >
       <!-- ... -->
    </div>
</x-filament-widgets::widget>

If I remove the loadedOnRequest(), then they are always loaded, but I dont really want that. I only want them to load when this widget is rendered. Am I missing something?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

filament v3 assets not loading on production
FilamentFFilament / ❓┊help
2y ago
Ngnix not loading dynamic assets in production
FilamentFFilament / ❓┊help
3y ago
Deploy to shared hosting, not loading assets.
FilamentFFilament / ❓┊help
3y ago
Assets Not Found on Server
FilamentFFilament / ❓┊help
2y ago