N
Nuxt9mo ago
Phillip

Is there a way to prefetch the next page which has content that is being injected by javascript?

I have a page /welcome/payment-method where I load a Stripe UI payment element. Stripe has a function paymentElement.mount('#payment-element'), so basically, it looks for a DOM element with the id #payment-element. However, injecting the Stripe script and mounting the element takes time. I would like to show the form immediately. Is there way I can load the stripe script + mount the div#payment-element before the user visits the page /welcome/payment-method? Can I prepare this while the user is on page /welcome/intro or something? I hope my question is clear. I'm happy to explain further. Thank you!
1 Reply
Phillip
PhillipOP9mo ago
@L422Y thanks for your ideas! I'm having troubles to follow you quite frankly. I barely have used mutation observers but you mean I should listen to DOM changes? Or what should I observe?
Your solution would still mean that paymentElement.mount('#payment-element') needs to be run on /welcome/payment-method, correct? => meaning it'll still take a while before the form shows up for the user.
Want results from more Discord servers?
Add your server