Blaze is a Blade template compiler from the Livewire team that reduces component rendering overhead as your application scales. It works as a drop-in replacement for the default Blade compiler and offers three levels of optimization — from an optimized compiler to compile-time folding that pre-renders components into static HTML.
- Optimized compiler with up to 97% overhead reduction
- Memoization for caching repeated component renders
- Compile-time folding that pre-renders static components into HTML
- Built-in profiler with flame charts and per-component timing
- No changes required to existing Blade templates
Built-in profiler
Blaze includes a built-in profiler that generates flame charts and per-component timing breakdowns:
Blaze::debug();
This helps identify which components benefit most from optimization.
Optimized Compiler
The default tier replaces Laravel's Blade compiler with one that turns templates into optimized PHP functions. It requires no configuration and works as a drop-in replacement, claiming up to 97% overhead reduction.
Memoization
The second tier caches the rendered output of components that receive identical props. This is useful for components that appear many times on a page with the same data, such as icons or avatar images.
Compile-Time Folding
The third tier pre-renders components into static HTML at compile time, removing runtime overhead entirely. This works for components whose output doesn't depend on runtime data.
Usage
You can optimize individual components by adding the @blaze directive, or target entire directories at once:
Blaze::optimize() ->in(resource_path('views/components/app')) ->in(resource_path('views/components/admin'));
Check out Blaze.dev for complete details.