Any performance cost to making a function a worklet? #3729
-
If I have a function that is mostly called on the JS side, but I also want to be able to call it on the UI side, are there any performance costs to just making that function a worklet? Or would it be better to make a separate worklet version of that function for calling it from the UI side (e.g. have both |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey, there's no performance cost of calling a workletized function from the main JS context (it's just a regular function). Also, there's no need to have two versions of the same function, one workletized and the other not. The only cost is related to bundle size, because the function body of each worklet needs to be converted to a string by Reanimated Babel plugin so it can be |
Beta Was this translation helpful? Give feedback.
Hey, there's no performance cost of calling a workletized function from the main JS context (it's just a regular function). Also, there's no need to have two versions of the same function, one workletized and the other not. The only cost is related to bundle size, because the function body of each worklet needs to be converted to a string by Reanimated Babel plugin so it can be
eval
'd on UI context.