<whatever-compo /> VS <component /> performance ? #12153
Replies: 3 comments 5 replies
-
<FooComp />
<component :is="hasSth ? FooComp : BarComp" /> |
Beta Was this translation helpful? Give feedback.
-
The answer is no. <component is="MyComp"/> Is compiled into something like: h(resolveDynamicComponent('MyComp')) While <my-comp/> Is compiled into something like: h(MyComp) If const MyComp = resolveComponent('MyComp') I'm not sure if Vue optimizes But I think that what the documentation is trying to express is that, during runtime, the |
Beta Was this translation helpful? Give feedback.
-
Nice, thanks. But, going back to my original question...
Do these dynamic components get re-resolved all the time or it works more like a computed? Like: ok, you DO have some performance penalty on first resolve, but as long as the compo name doesn't change (so to speak) you don't get that again. In other words, does that result from the compo resolution gets saved/cached/whatever in any way ? If there was a |
Beta Was this translation helpful? Give feedback.
-
Probably this has been asked before (couldn't find anything though), what about the performance of
<component>
VS the component itself ?I just read the documentation and it's pretty clear (I would say):
Does this mean that if I make the biggest most robust app ever, and every single component (on template) is
<component :is="'my-compo'" />
instead of...
<my-compo />
...it'll all be the same performance-wise? (except, of course for loosing let's say a processor microtic while compiling the template because it checks the "is" prop instead of taking the compo name from tag name)
And what if instead of passing a string to the "is" prop I were to use a reactive ?
Essentially, I'm trying to provide a theme-like approach where you can "extend" (change) just any "core" compo (not just styles), I've already done this (don't know how to test performance though) but with just 2 or 3 "main" compos, and was wondering how far down that rabbit hole can I go before everything comes crashing down.
Based on what the docs say, there should be no difference in doing just anything only using
<component>
...but, you never know, maybe vüe3 devs can shed some light on this ?Thanks in advance =3
Beta Was this translation helpful? Give feedback.
All reactions