Data property size awareness #257
Replies: 1 comment 1 reply
-
|
Yep, overloading the data property like that will slow down the entire process. Part of the issue is that the entire wire payload (which includes the data property) has to be passed back and forth. CBWire includes checksum validation for security, and due to its nature the wire component is re-instantiated and populated on every request so it needs all of the data properties to do this. Perhaps we can add a hint/warning about overloading the data property added to the docs. What do you think @grantcopley ? FWIW, livewire does only send updates for changed data properties, however it still needs the "state" as well to validate the checksum of the "state" and instantiate the wire component before updating any values or making any method calls. I have been in the same situation many times, specifically in regards to pagination. If your dataset is large and you would prefer not to hit the database on every wire update request my solution is almost always to implement caching, thus taking a slight hit on the initial render ( onMount() ) and then getting a massive performance boost on all subsequent wire requests. You can further improve the end-user experience by using lazy loading so the initial DB query time does not slow down the initial rendering of the entire page. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I just ran into this issue where the onclick action that was running took 6ms, but the page took 1.5 seconds to run. It turns out that when the action is fired, cbwire/livewire will send all the data that is in the data variable to the browser whether it needs it or not. The browser takes time to evaluate all the data that is being processed. To summarize, i was using pagination but i was storing all the records in the cbwire data scope and I was also storing a subset of the records thinking that it should be much quicker; but it wasn't
So until this framework is "smarter" about how data is replaced in the DOM, this is something that should be kept in mind.
DONT CLUTTER THE DATA VARIABLE
Beta Was this translation helpful? Give feedback.
All reactions