DEV Community

Discussion on: Should you use created() or mounted() in Vue?

john_papa profile image
John Papa

Thanks for the article.

Regarding api calls in created vs mounted , I haven’t experienced any speed difference for putting fetch calls there. I’m curious , hav suoi and if so - would you mind sharing the scenario?

Another thought that might matter to some ... SSR doesn’t have mounted - so that would be a good reason to use created (if SSR matters to you)

firstclown profile image
Joe Erickson Author

Sorry, I didn't mean to imply that is was actually faster, but that is it user perceived faster. Since the API call is kicked off before the component is rendered, it will already be in progress for when the component is shown on the screen and the user's perception of the loading time is started. This would then cut down on the perceived wait time that the user has to endure before interacting with your component. I'll update the article to reflect this.

And that's an interesting note Server-Side Rendering. Thank you for that.