I am quite new to front-end development and I am sorry if this is a damn question.
I am using Gatsby project to create my web site. In this web site, I have multiple pages and one of the pages adds content to an element after its page is created.
For this, I use something like below.
useEffect(() => {
addView()
return () => {
console.log("unmounted");
}
}, [])
This works as expected. However, addView() function takes a lot of time to load so I would like to preload this when users arrive the home page.
I assume I can achieve something like this by triggering addView() after gatsby prefetches the page instead of using useEffect(). But I am not sure how I can know when gatsby prefetch is done.
So my question is, is there any way to trigger a function when prefetch is done and a certain element is created in another page?