Is there a way to defer loading a a component?
Answered
Scottish Fold posted this in #help-forum
Scottish FoldOP
Currently I am dynamically loading a component in using
Is there a way to defer loading my component so that it is preloaded in the background rather than when it is needed?
next/dynamic. I'm loading in a confetti animation that only renders once my form is submitted. The problem with using next/dynamic is that when the form is successfully submitted, there is a bit of a delay before the confetti animation shows. It works fine if I don't dynamically load in the confetti component, but that means the initial bundle for my page is a lot bigger.Is there a way to defer loading my component so that it is preloaded in the background rather than when it is needed?
Answered by Scottish Fold
My issue was that I wasn't rendering the animation component until the form submission succeeded, I resolved this by rendering the animation component upfront and preventing it from playing until the form submission succeeded.
1 Reply
Scottish FoldOP
My issue was that I wasn't rendering the animation component until the form submission succeeded, I resolved this by rendering the animation component upfront and preventing it from playing until the form submission succeeded.
Answer