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...
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")')
);
}