PHPackages                             artisanpack-ui/performance - 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. [Caching](/categories/caching)
4. /
5. artisanpack-ui/performance

ActiveLibrary[Caching](/categories/caching)

artisanpack-ui/performance
==========================

Comprehensive performance optimization toolkit for Laravel applications: image optimization, JS/CSS strategies, resource hints, speculative loading, page and fragment caching, query analysis, and real-user performance monitoring.

1.1.0(1mo ago)0303[1 issues](https://github.com/ArtisanPack-UI/performance/issues)MITPHPPHP ^8.2

Since Jul 4Pushed 1mo agoCompare

[ Source](https://github.com/ArtisanPack-UI/performance)[ Packagist](https://packagist.org/packages/artisanpack-ui/performance)[ RSS](/packages/artisanpack-ui-performance/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (23)Versions (4)Used By (0)

ArtisanPack UI Performance
==========================

[](#artisanpack-ui-performance)

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

A comprehensive performance optimization toolkit for Laravel applications. Image optimization, JS/CSS strategies, resource hints, speculative loading, page and fragment caching, database query analysis, and a real-user performance monitoring dashboard — with Livewire, React, **and** Vue front-ends.

Highlights
----------

[](#highlights)

- 🖼 **Image optimization** — WebP/AVIF conversion, responsive sizes, dominant-color LQIP, lazy loading
- ⚡ **JS &amp; CSS strategies** — deferred / async / conditional scripts, critical CSS extraction, HTML minification
- 🔮 **Speculative loading** — Speculation Rules API for prefetch and prerender
- 🔗 **Resource hints &amp; Early Hints** — preconnect, dns-prefetch, preload, HTTP 103 Early Hints
- 🗄 **Caching** — page cache, fragment cache, tag-based invalidation, cache warming
- 🧮 **Database optimization** — N+1 detection, slow query logging, query cache, index suggestions
- 📊 **Real-user monitoring** — Web Vitals collection, aggregation, and a Livewire admin dashboard
- 🤖 **AI features** — query-insight and portfolio-level optimization suggestions, with Livewire, React, and Vue trigger components in the box
- 🧰 **Artisan tooling** — `perf:install`, `perf:warm-cache`, `perf:purge-cache`, `perf:aggregate-metrics`, `perf:critical-css`, `perf:generate-webp`, `perf:suggest-indexes`
- 🎛 **Every feature is opt-in** — nothing runs until you toggle it on

Requirements
------------

[](#requirements)

- PHP 8.2+ for Laravel 10, 11, or 12
- PHP 8.3+ for Laravel 13
- `ext-gd` or `ext-imagick` for image optimization
- Livewire 3 (optional — only required for the bundled dashboard components)

Installation
------------

[](#installation)

```
composer require artisanpack-ui/performance
php artisan perf:install
```

The install command publishes config, runs migrations, validates environment requirements, and prints the dashboard gate stub plus next steps.

### Non-interactive install (CI/CD)

[](#non-interactive-install-cicd)

```
php artisan perf:install --no-interaction --force
```

### React / Vue projects

[](#react--vue-projects)

Front-end companion is published as `@artisanpack-ui/performance` with subpath exports:

```
// React
import { PerformanceDashboard, MetricsChart } from '@artisanpack-ui/performance/react'

// Vue
import MetricsChart from '@artisanpack-ui/performance/vue/MetricsChart.vue'

// Vanilla helpers
import { reportWebVitals } from '@artisanpack-ui/performance/web-vitals'
import { applySpeculativeRules } from '@artisanpack-ui/performance/speculative-rules'
```

The React/Vue components hit the same JSON API the Livewire dashboard does, so back-end behavior is identical regardless of the chosen front-end.

Quick start
-----------

[](#quick-start)

```
{{-- Drop the RUM collector into your layout --}}
@perfMonitor

{{-- Emit Speculation Rules for a prefetch/prerender ruleset --}}
@speculativeRules('main-nav')

{{-- Render the admin dashboard behind your gate --}}

```

```
use ArtisanPackUI\Performance\Facades\Performance;

// Convert an image to WebP + AVIF and generate responsive sizes
Performance::optimizeImage($path, [
    'sizes'   => [320, 640, 1024],
    'formats' => ['webp', 'avif'],
]);

// Cache a fragment for 10 minutes, tagged for invalidation
$html = Performance::fragmentRemember('product.card.'.$product->id, 600, function () use ($product) {
    return view('products.card', ['product' => $product])->render();
}, tags: ['product:'.$product->id]);

// Register a script with a load strategy
Performance::script(asset('js/analytics.js'))
    ->name('analytics')
    ->defer()
    ->loadOn('interaction');
```

Documentation
-------------

[](#documentation)

- [docs/home.md](docs/home.md) — documentation home
- [docs/guides.md](docs/guides.md) — feature walkthroughs
- [docs/api.md](docs/api.md) — programmatic API reference

### AI features

[](#ai-features)

The performance package registers two AI features via `artisanpack-ui/ai`. Both are gated by the `artisanpack.ai.features..enabled` toggle and will no-op when the toggle is off.

Feature keyPurposeLivewireReactVue`performance.query_insight`Explain why a slow query is slow, suggest indexes and rewrites (never runs DDL).`perf-ai-query-insight-panel``QueryInsightPanel``QueryInsightPanel``performance.optimization_suggestion`Look at aggregate metrics over a date range and recommend where to focus optimization work.`perf-ai-optimization-suggestion-panel``OptimizationSuggestionPanel``OptimizationSuggestionPanel`The React and Vue components live inside this package (not in `@artisanpack-ui/react` / `@artisanpack-ui/vue`) so both frameworks are supported without adding a coupling to the shared UI packages.

```
{{-- Livewire --}}

```

```
// React
import { QueryInsightPanel, OptimizationSuggestionPanel } from '@artisanpack-ui/performance/react';

```

```

import { QueryInsightPanel, OptimizationSuggestionPanel } from '@artisanpack-ui/performance/vue';

```

The React and Vue triggers POST to `POST /api/performance/ai/query-insight` and `POST /api/performance/ai/optimization-suggestion`. Responses are shaped as `{ data: , feature_key: string }`. Disabled features return `409`; missing credentials return `412`; validation errors return `422`.

### Feature guides

[](#feature-guides)

- [Image optimization](docs/guides/image-optimization.md)
- [JavaScript &amp; CSS strategies](docs/guides/javascript-css-strategies.md)
- [Caching](docs/guides/caching.md)
- [Database optimization](docs/guides/database-optimization.md)
- [Monitoring &amp; dashboard](docs/guides/monitoring-dashboard.md)
- [Speculative loading](docs/guides/speculative-loading.md)
- [Media library integration](docs/guides/media-library-integration.md)

### API reference

[](#api-reference)

- [Services](docs/api/services.md)
- [Models](docs/api/models.md)
- [Events](docs/api/events.md)
- [Helpers](docs/api/helpers.md)
- [Blade directives](docs/api/blade-directives.md)
- [Middleware](docs/api/middleware.md)
- [Livewire components](docs/api/livewire.md)
- [Traits](docs/api/traits.md)
- [Artisan commands](docs/api/artisan.md)
- [JavaScript API](docs/api/javascript.md)

### Benchmarks

[](#benchmarks)

- [Overview](docs/benchmarks.md)
- [Client-side methodology](docs/benchmarks/client-side.md)
- [Server-side methodology](docs/benchmarks/server-side.md)

### Customization

[](#customization)

- [Overview](docs/customization.md)
- [View customization](docs/customization/views.md)

### Security

[](#security)

- [Overview](docs/security.md)
- [Audit — v1.0.0](docs/security/audit-1.0.0.md)

### Development

[](#development)

- [Overview](docs/development.md)
- [Code style](docs/development/code-style.md)

Artisan commands
----------------

[](#artisan-commands)

CommandPurpose`perf:install`Publish config, migrate, validate environment, print gate stub`perf:warm-cache`Pre-populate page/fragment cache for configured URLs`perf:purge-cache`Flush the page and/or fragment cache (optional tag filters)`perf:aggregate-metrics`Roll raw RUM samples up into hourly/daily buckets`perf:critical-css`Extract critical CSS for configured routes`perf:generate-webp`Batch-convert existing images to WebP/AVIF`perf:suggest-indexes`Analyze slow queries and suggest missing indexesSchedule the recurring commands in `bootstrap/app.php` (Laravel 11+):

```
->withSchedule(function (Schedule $schedule): void {
    $schedule->command('perf:aggregate-metrics')->hourly();
    $schedule->command('perf:warm-cache')->everyThirtyMinutes();
    $schedule->command('perf:suggest-indexes')->daily();
})
```

Testing
-------

[](#testing)

```
composer test                                # full suite
./vendor/bin/pest tests/Feature/Cache        # one suite
./vendor/bin/pest --filter=speculative       # one test
composer bench                               # benchmark suite (opt-in)
```

The package ships with 800+ Pest tests covering every service, model, Livewire component, Artisan command, middleware, event, and listener.

Configuration
-------------

[](#configuration)

Every feature toggle in `config/artisanpack/performance.php` has a matching `PERF_*` environment variable, so you can flip features per environment without code changes:

```
'features' => [
    'image_optimization'  => env('PERF_IMAGE_OPTIMIZATION', false),
    'script_optimization' => env('PERF_SCRIPT_OPTIMIZATION', false),
    'critical_css'        => env('PERF_CRITICAL_CSS', false),
    'resource_hints'      => env('PERF_RESOURCE_HINTS', false),
    'speculative_loading' => env('PERF_SPECULATIVE_LOADING', false),
    'html_minification'   => env('PERF_HTML_MINIFICATION', false),
    'early_hints'         => env('PERF_EARLY_HINTS', false),
    'page_cache'          => env('PERF_PAGE_CACHE', false),
    'fragment_cache'      => env('PERF_FRAGMENT_CACHE', false),
    'cache_warming'       => env('PERF_CACHE_WARMING', false),
    'query_optimization'  => env('PERF_QUERY_OPTIMIZATION', false),
    'monitoring'          => env('PERF_MONITORING', false),
    'dashboard'           => env('PERF_DASHBOARD', false),
],
```

The published configuration file is heavily commented — every section documents what it does and the trade-offs of each option.

Upgrading
---------

[](#upgrading)

See [CHANGELOG.md](CHANGELOG.md) for release history. Version-to-version upgrade notes will land in `UPGRADING.md` once there is a v1.x → v2.x transition to document.

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

[](#contributing)

As an open source project, this package is open to contributions from anyone. Please [read through the contributing guidelines](CONTRIBUTING.md) to learn more about how you can contribute to this project.

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance90

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~3 days

Total

2

Last Release

45d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ba2a2c40c9a93470595cd10701d2291434f3a7db61862d9700a9e69e31608c6c?d=identicon)[JacobMartellaWebDesign](/maintainers/JacobMartellaWebDesign)

---

Top Contributors

[![ViewFromTheBox](https://avatars.githubusercontent.com/u/8247489?v=4)](https://github.com/ViewFromTheBox "ViewFromTheBox (72 commits)")

---

Tags

cachinglaravellaravel-packageoptimizationperformancephpspeed

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/artisanpack-ui-performance/health.svg)

```
[![Health](https://phpackages.com/badges/artisanpack-ui-performance/health.svg)](https://phpackages.com/packages/artisanpack-ui-performance)
```

###  Alternatives

[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k161.4k2](/packages/mike-bronner-laravel-model-caching)[illuminate/cache

The Illuminate Cache package.

12937.6M2.0k](/packages/illuminate-cache)[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21114.2k](/packages/iazaran-smart-cache)

PHPackages © 2026

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