You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-23Lines changed: 9 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,41 +35,27 @@ Blaze is designed as a drop-in replacement for anonymous Blade components. It su
35
35
> [!IMPORTANT]
36
36
> When using `@aware`, both the parent and child must use Blaze for the values to propagate correctly.
37
37
38
-
### Usage
38
+
### Getting started
39
39
40
-
Enable Blaze in your `AppServiceProvider`.
41
-
42
-
This will optimize all [anonymous component paths](https://laravel.com/docs/12.x/blade#anonymous-component-paths).
40
+
Enable Blaze in your `AppServiceProvider`:
43
41
44
42
```php
45
43
use Livewire\Blaze\Blaze;
46
44
47
-
/**
48
-
* Bootstrap any application services.
49
-
*/
50
45
public function boot(): void
51
46
{
52
47
Blaze::optimize();
53
48
}
54
49
```
55
50
56
-
> [!CAUTION]
57
-
> This can break your app if you rely on features not supported by Blaze. Consider only enabling Blaze for certain directories or components.
58
-
59
-
### Configuration
60
-
61
-
To only enable Blaze for specific directories or components:
62
-
63
-
**Define component paths:**
51
+
This optimizes all [anonymous component paths](https://laravel.com/docs/12.x/blade#anonymous-component-paths). You can also scope Blaze to specific directories or enable it per-component:
64
52
65
53
```php
66
54
Blaze::optimize()
67
55
->in(resource_path('views/components/icons'))
68
56
->in(resource_path('views/components/ui'));
69
57
```
70
58
71
-
**Or use the @blaze directive:**
72
-
73
59
```blade
74
60
@blaze
75
61
@@ -78,7 +64,7 @@ Blaze::optimize()
78
64
</button>
79
65
```
80
66
81
-
To enable different strategiesper directory/component:
67
+
Different [optimization strategies](#optimization-strategies) can be enabled per directory or component:
82
68
83
69
```php
84
70
Blaze::optimize()
@@ -93,13 +79,13 @@ Blaze::optimize()
93
79
94
80
## Optimization strategies
95
81
96
-
Blaze offers three optimization strategies:
82
+
By default, Blaze uses function compilation - a reliable strategy that behaves identically to standard Blade but eliminates 91-97% of the rendering overhead. For specific scenarios, two optional strategies can be enabled per-component or directory:
97
83
98
84
| Strategy | Param | When to use |
99
-
|----------|----------|-------------|
100
-
|**[Compiler](#function-compiler)**| (default) |For most components - reliable optimization with zero concerns about caching or stale data|
101
-
|**[Memoization](#runtime-memoization)**|`memo`|For self-closing components like icons or avatars that appear many times on a page with the same props |
102
-
|**[Folding](#compile-time-folding)**|`fold`|For maximum performance - when you understand the folding model and your component's data flow|
85
+
|----------|-------|-------------|
86
+
|**[Compiler](#function-compiler)**| (default) |General use - works like Blade, 91-97% faster|
87
+
|**[Memoization](#runtime-memoization)**|`memo`|Icons/avatars repeated with same props |
88
+
|**[Folding](#compile-time-folding)**|`fold`|Static components - maximum performance|
0 commit comments