Skip to content

[TwigComponent] Improve performance for complex use-cases #2812

Closed
@adri

Description

@adri

Firstly, great work and nice to see a component based way of working for Symfony.

Scenario

Creating components like shadcn with Twig Components is great. However, when using a lot of them, the performance degrades quickly. Especially when adding popovers with buttons in them for each cell.

  1. There seems to be overhead with the rendering of each component
  2. The response size gets very large (4 MB in the example) even compressed it takes quite a while for the browser to download and parse

Reproducer

Image
  1. Checkout the reproducer
  2. composer install
  3. symfony server:start

Solutions

I'm probably switching back to simple HTML elements again (<button class="ghost">) and use Tailwinds @apply for different variants. Of course, I'd prefer to keep using the component approach.

Phoenix LiveView solved the 2. problem with an optimization, see Optimization #1: splitting statics from dynamics. This way the response size doesn't grow very large.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions