2019 | Async Vue.js Components | Alexander Schwartz 3 Problem 1: Your application is big and starts slow in the browser Solution 1: Use Webpack code splitting to load components only when needed Problem 2: When the user visits the part of the application for the first time, there is a delay, and loading might fail Solution 2: Show a placeholder while loading, and an error message if loading fails
2019 | Async Vue.js Components | Alexander Schwartz 9 Situation Behaviour Remedy Component loads fast or already loaded, delay set to 0 Flickering Increase delay
2019 | Async Vue.js Components | Alexander Schwartz 10 Situation Behaviour Remedy Component loads fast or already loaded, delay set to 0 Flickering Increase delay Component loads slowly Loading screen appears after delay, then the component (works as designed)
2019 | Async Vue.js Components | Alexander Schwartz 11 Situation Behaviour Remedy Component loads fast or already loaded, delay set to 0 Flickering Increase delay Component loads slowly Loading screen appears after delay, then the component (works as designed) Component fails to load after for example network error Error component shows; no retry will be issued on next rendering Provide link to user to reload application OR re-register component Vue.component("comp", c)
2019 | Async Vue.js Components | Alexander Schwartz 12 Situation Behaviour Remedy Component loads fast or already loaded, delay set to 0 Flickering Increase delay Component loads slowly Loading screen appears after delay, then the component (works as designed) Component fails to load after for example network error Error component shows; no retry will be issued on next rendering Provide link to user to reload application OR re-register component Vue.component("comp", c) Timeout exceeded loading component Error component shows; late response will be ignored; no retry will be issued Don’t specify timeout OR re- register component as above
2019 | Async Vue.js Components | Alexander Schwartz 13 Situation Behaviour Remedy Component loads fast or already loaded, delay set to 0 Flickering Increase delay Component loads slowly Loading screen appears after delay, then the component (works as designed) Component fails to load after for example network error Error component shows; no retry will be issued on next rendering Provide link to user to reload application OR re-register component Vue.component("comp", c) Timeout exceeded loading component Error component shows; late response will be ignored; no retry will be issued Don’t specify timeout OR re- register component as above
| Async Vue.js Components | Alexander Schwartz 14 Vue.js dynamic and async components https://vuejs.org/v2/guide/components-dynamic-async.html Lazy Loading with Vue Router https://router.vuejs.org/guide/advanced/lazy-loading.html Example by @chrisfritz – see lazyLoadView() at end of file https://github.com/chrisvfritz/vue-enterprise-boilerplate/blob/master/src/router/routes.js @ahus1de