© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
9 replies
Raj Siva-Rajah

Exclude specific pages from JS asset registration

Anyone know how to exclude a couple of pages when registering a JS asset? I need this script running in the background on 99% of pages so I'm not sure that lazy loading is the right approach...
Solution
As an example:

if (! function_exists('is_panel_auth_route')) {
    function is_panel_auth_route(): bool
    {
        $authRoutes = [
            '/login',
            '/password-reset',
            '/register',
            '/email-verification',
        ];

        return Str::of(Request::path())->contains($authRoutes);
    }
}

if (! is_panel_auth_route()) {
  FilamentView::registerRenderHook(
      name: 'panels::body.end',
      fn (): string => Blade::render('@vite("resources/js/my-script.js")')
  );
}
if (! function_exists('is_panel_auth_route')) {
    function is_panel_auth_route(): bool
    {
        $authRoutes = [
            '/login',
            '/password-reset',
            '/register',
            '/email-verification',
        ];

        return Str::of(Request::path())->contains($authRoutes);
    }
}

if (! is_panel_auth_route()) {
  FilamentView::registerRenderHook(
      name: 'panels::body.end',
      fn (): string => Blade::render('@vite("resources/js/my-script.js")')
  );
}
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Exclude from live()
FilamentFFilament / ❓┊help
2y ago
Exclude assets from publish
FilamentFFilament / ❓┊help
2y ago
Exclude rows from reordering completely
FilamentFFilament / ❓┊help
2y ago
exclude form component from submission
FilamentFFilament / ❓┊help
3y ago