PHPackages                             vlados/laravel-blade-crawler-detect - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. vlados/laravel-blade-crawler-detect

ActiveLibrary[Templating &amp; Views](/categories/templating)

vlados/laravel-blade-crawler-detect
===================================

Boost Lighthouse and PageSpeed scores by hiding cookie banners, chat widgets and heavy scripts from crawlers via two Blade directives. Octane-safe.

v0.5.0(2mo ago)05.1k[3 PRs](https://github.com/vlados/laravel-blade-crawler-detect/pulls)MITPHPPHP ^8.1

Since Aug 2Pushed 6d ago1 watchersCompare

[ Source](https://github.com/vlados/laravel-blade-crawler-detect)[ Packagist](https://packagist.org/packages/vlados/laravel-blade-crawler-detect)[ Docs](https://github.com/vlados/laravel-blade-crawler-detect)[ RSS](/packages/vlados-laravel-blade-crawler-detect/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (6)Dependencies (12)Versions (105)Used By (0)

Laravel Blade Crawler Detect
============================

[](#laravel-blade-crawler-detect)

[![Latest Version on Packagist](https://camo.githubusercontent.com/db7477b859df9bb319b5dd3ffded155a8b8b23dac5d924811b1e602eb6883414/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f766c61646f732f6c61726176656c2d626c6164652d637261776c65722d6465746563742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vlados/laravel-blade-crawler-detect)[![Total Downloads](https://camo.githubusercontent.com/0df252f366266574449d1850bd0a1adb1bdc471536d04ac17faa1ad960838c6f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f766c61646f732f6c61726176656c2d626c6164652d637261776c65722d6465746563742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vlados/laravel-blade-crawler-detect)[![PHP Version Require](https://camo.githubusercontent.com/9555e93b3c94d624692071e621f2387e4e9c0468221f316cc037b3a258586095/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f766c61646f732f6c61726176656c2d626c6164652d637261776c65722d6465746563742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vlados/laravel-blade-crawler-detect)[![License](https://camo.githubusercontent.com/dbc54d602de330a0368e9e314d147007485ebf60e54668ce1c0a0b7aa9c5976c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f766c61646f732f6c61726176656c2d626c6164652d637261776c65722d6465746563742e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

**Two Blade directives that boost your Lighthouse and PageSpeed scores without changing a thing for real users.**

Wrap your cookie banner, chat widget, analytics scripts, video embeds and other heavy chrome in `@user ... @enduser`. Bots like Googlebot, Lighthouse and PageSpeed will skip it entirely; humans see the same experience as before.

```
@user

@enduser
```

Result: lighter HTML for crawlers, better Core Web Vitals, more crawl budget spent on the content that actually matters — and zero JS or middleware changes.

---

Why developers reach for this
-----------------------------

[](#why-developers-reach-for-this)

- **Better Lighthouse / PageSpeed scores.** Audit tools render the page like a low-power phone. Strip the widgets they don't need and the score climbs.
- **Better Core Web Vitals.** LCP, INP and CLS all benefit when crawlers stop pulling in chat libraries and consent banners.
- **More crawl budget for real content.** Googlebot fetches less JS, indexes more pages.
- **One-line wrap.** No middleware, no service container plumbing, no view composers — just Blade.
- **Octane-safe.** Reads the user agent per request, so long-running workers don't serve stale data.
- **ReDoS-hardened.** User-agent input is clamped before any regex runs.
- **Up to date.** Built on [`jaybizzle/crawler-detect`](https://github.com/JayBizzle/Crawler-Detect) (thousands of bots, regularly updated) plus Lighthouse and PageSpeed out of the box.

Install
-------

[](#install)

```
composer require vlados/laravel-blade-crawler-detect
```

That's it — the service provider auto-registers. No config file, no migrations, no env vars.

**Requires** PHP 8.1+ and Laravel 10, 11, 12 or 13.

The two directives
------------------

[](#the-two-directives)

### `@user` — render only for humans

[](#user--render-only-for-humans)

Anything that hurts your audit score, is invisible to bots anyway, or just doesn't need to ship to crawlers.

```
{{-- Cookie / consent banners --}}
@user

@enduser

{{-- Chat widgets, support bubbles --}}
@user

@enduser

{{-- Heavy analytics / tag managers --}}
@user

@enduser

{{-- Lazy-mounted Vue / Livewire / Alpine widgets --}}
@user

@enduser
```

### `@unlessuser` — render only for crawlers

[](#unlessuser--render-only-for-crawlers)

Server-render the SEO-friendly equivalent of something you ship as JS to humans.

```
{{-- Humans get the interactive gallery --}}
@user

@enduser

{{-- Crawlers get plain, indexable images --}}
@unlessuser
    @foreach ($product->images as $image)

    @endforeach
@enduser
```

Real-world wins
---------------

[](#real-world-wins)

Wrap this in `@user`Why it helpsCookie consent bannerRemoves ~200ms LCP delay on LighthouseIntercom / Drift / Zendesk widgetRemoves 100-300KB of third-party JSGoogle Tag Manager / AnalyticsRemoves blocking script + network round-tripOptimizely / VWO / experimentation SDKsRemoves render-blocking scriptHotjar / FullStory / session recordingRemoves 50-150KB of third-party JSYouTube / Vimeo iframe embedsRemoves a heavy iframe + its JSMapbox / Google Maps iframesRemoves a heavy iframe + its tile fetchesCarousel / slider librariesRemoves JS + CSS that crawlers don't renderChat triggers, modal openersRemoves interactive chrome bots can't clickWhat "crawler" means
--------------------

[](#what-crawler-means)

Detection is delegated to [`jaybizzle/crawler-detect`](https://github.com/JayBizzle/Crawler-Detect), a battle-tested PHP library that ships a regex covering thousands of bots — Googlebot, Bingbot, DuckDuckBot, AhrefsBot, SemrushBot, Applebot, and so on.

This package additionally treats these as crawlers, since they typically run as audits rather than real visits:

- `Chrome-Lighthouse`
- `Google Page Speed`

Want to add your own? You can swap or wrap the `CrawlerDetect` instance through Laravel's container.

Performance
-----------

[](#performance)

The crawler regex is compiled **once per process** (so Octane workers compile it at boot, traditional FPM workers compile it on first hit). Each render only does:

1. One `substr` to clamp the UA to 2KB.
2. One `preg_replace` for exclusions.
3. One `preg_match` against the compiled crawler pattern.

No DB queries, no cache lookups, no allocations beyond the strings above.

Octane / Swoole / RoadRunner
----------------------------

[](#octane--swoole--roadrunner)

Safe by design. The user agent is read from the current request **inside** the directive's closure, so long-running workers always see the active request's UA — never a stale one cached at boot.

When NOT to use this
--------------------

[](#when-not-to-use-this)

This package is a tool for hiding things crawlers don't need (heavy widgets, third-party scripts, modal chrome). It is **not** a tool for showing crawlers different *content* than you show users — that's [cloaking](https://developers.google.com/search/docs/essentials/spam-policies#cloaking) under Google's spam policies and can earn a manual penalty. Use `@unlessuser` for SSR-equivalents of things you JS-render for humans, not for keyword stuffing.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md).

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/vlados/.github/blob/main/CONTRIBUTING.md).

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Vladislav Stoitsov](https://github.com/vlados)
- [`jaybizzle/crawler-detect`](https://github.com/JayBizzle/Crawler-Detect) — the regex behind this package
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance93

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 52.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~271 days

Recently: every ~335 days

Total

6

Last Release

75d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/20ebf35eac0da0d3775f3a64bdd9dc0e9dfa11bc9a3c3ee9db92deef9dbf8bd8?d=identicon)[vlados](/maintainers/vlados)

---

Top Contributors

[![vlados](https://avatars.githubusercontent.com/u/46914?v=4)](https://github.com/vlados "vlados (30 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (11 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (10 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (6 commits)")

---

Tags

blade-directivesbot-detectioncrawler-detectionlaravellaravel-packagelaravelperformancebladecrawleruser agentoctanebotseolighthousecookie-bannerPageSpeedcore-web-vitalsblade-directivegooglebot

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/vlados-laravel-blade-crawler-detect/health.svg)

```
[![Health](https://phpackages.com/badges/vlados-laravel-blade-crawler-detect/health.svg)](https://phpackages.com/packages/vlados-laravel-blade-crawler-detect)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k102.4M1.4k](/packages/spatie-laravel-permission)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[filament/support

Core helper methods and foundation code for all Filament packages.

2331.0M245](/packages/filament-support)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[spatie/laravel-blade-comments

Add debug comments to your rendered output

180335.8k](/packages/spatie-laravel-blade-comments)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
