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
First up – we love Laravel. We just launched our new rebrand (gigsalad.com, check us out!) using Laravel 11.x.
But unfortunately, we've discovered that utilizing Blade components is far slower than alternatives – and we're having to consider some major refactoring to reduce TTFB.
We're obviously not the first to find this. For some good reading, see the following:
Inspired by the benchmarking in the latter thread, we put together our own suite of benchmarks, including the use of a third-party caching directive (blade-boost-directive) and a custom @loop (as in the Laravel News article).
As you can see, <x-empty-component> takes approximately 11x as long to be included 100x as the outputting of 100 empty <div>s.
What is responsible for this overhead? How can it be improved? This isn't a purely academic pursuit – we're spending significantly more time on Blade rendering overhead than on database querying, booting, and other significant aspects of the application. Our Blade component usage (utilizing multiple components within loops for product listings) is not uncommon for a marketplace or e-commerce app like ours.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First up – we love Laravel. We just launched our new rebrand (gigsalad.com, check us out!) using Laravel 11.x.
But unfortunately, we've discovered that utilizing Blade components is far slower than alternatives – and we're having to consider some major refactoring to reduce TTFB.
We're obviously not the first to find this. For some good reading, see the following:
Inspired by the benchmarking in the latter thread, we put together our own suite of benchmarks, including the use of a third-party caching directive (blade-boost-directive) and a custom
@loop
(as in the Laravel News article).Here are our results when rendering 100 instances of Filament 3.x's badge component:
As you can see, the
<x-badge>
component takes 27x the length of time to render as does the vanilla HTML.To test whether this was a result of the PHP overhead inherent to the Filament components themselves, we put together the following sandbox environment comparing 100x empty elements included as a component: https://phpsandbox.io/e/x/irrm9?layout=EditorPreview&defaultPath=%2F&theme=dark&showExplorer=no&openedFiles=
As you can see,
<x-empty-component>
takes approximately 11x as long to be included 100x as the outputting of 100 empty<div>
s.What is responsible for this overhead? How can it be improved? This isn't a purely academic pursuit – we're spending significantly more time on Blade rendering overhead than on database querying, booting, and other significant aspects of the application. Our Blade component usage (utilizing multiple components within loops for product listings) is not uncommon for a marketplace or e-commerce app like ours.
Beta Was this translation helpful? Give feedback.
All reactions