I'm using the laravel blades files and I wanted to know if this methodology can slow my site. This is my structure of files:
show.blade.php file:
<div class="table-sections">
...
@include('elements/table',['name' => 'table1','blocks' => $blocks1])
...
@include('elements/table',['name' => 'table2','blocks' => $blocks2])
...
</div>
table.blade.php file:
...
@foreach($blocks as $block)
...
@foreach($block['sections'] as $section)
...
@foreach($section['rows'] as $row)
...
@include('elements/row','row' => $row)
...
@endforeach
...
@endforeach
...
@endforeach
...
row.blade.php file :
...
@foreach($row['attributes'] as $attribute)
...
// Making the '<td>' elements with their respective attributes and html
...
@endforeach
...
I have a lot of nested 'foreach' block control sections, so I wanted to know if in this cases is better to not use the blades (for instance for the row.blade.php file)
What do you suggest?
Too much nesting, is really a bad practice in Laravel. we try to make our code clean, but that causes sometimes a performance tradeoff. thats why i ended up deciding to create a small library that flattens the blade on production, which improves the performance up to x10 times.
try it from here: https://packagist.org/packages/te-cho/compile-blades
basically, all it does is that it takes the blade file and it puts the includes and yields in one blade file without no includes nor yielding.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With