symfony / stimulus-bridge

Stimulus integration bridge for Symfony projects
https://symfony.com/ux
75 stars 15 forks source link

One controller called multiple time in one page #74

Closed Quenway closed 1 year ago

Quenway commented 1 year ago

Hi there,

I have a question about the best practice to do one simple thing.

I have one controller, it is called 3 times on a unique page. In this controller, I import the scoped CSS. I realize by doing that that my CSS is imported 3 times as well, or I don't want this (it's annoying in dev tools, the css appears multiple time)

So my question, is it a good practice to import the CSS into the controller ? If yes, how can I avoid the multiple CSS import ? If no, what can I do ? Put my import CSS into the app.js ?

Thanks for reading guys o/

weaverryan commented 1 year ago

Hi!

I realize by doing that that my CSS is imported 3 times as well, or I don't want this (it's annoying in dev tools, the css appears multiple time)

You see the same CSS is being downloaded onto the page from 3 separate files?

Is this controller using the "lazy" feature? In short, this should not happen: Webpack should be smart enough to package that CSS into just one file.

Quenway commented 1 year ago

I didn't see 3 files downloaded on the page, just I had 3 times the CSS in my dev tools inspector for the CSS class... I thought it was weird, but this morning I don't have this problem anymore...

If it comes back, I will investigate more and come back here to inform you.

Thanks for your reply bro o/