-
Notifications
You must be signed in to change notification settings - Fork 60
Lazy load components #1675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazy load components #1675
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| object-assign | ||
| (c) Sindre Sorhus | ||
| @license MIT | ||
| */ | ||
|
|
||
| /*! | ||
| * The buffer module from node.js, for the browser. | ||
| * | ||
| * @author Feross Aboukhadijeh <[email protected]> <http://feross.org> | ||
| * @license MIT | ||
| */ | ||
|
|
||
| /*! | ||
| * focus-trap 7.1.0 | ||
| * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE | ||
| */ | ||
|
|
||
| /*! | ||
| * tabbable 6.0.1 | ||
| * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE | ||
| */ | ||
|
|
||
| /*! Hammer.JS - v2.0.7 - 2016-04-22 | ||
| * http://hammerjs.github.io/ | ||
| * | ||
| * Copyright (c) 2016 Jorik Tangelder; | ||
| * Licensed under the MIT license */ |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /** | ||
| * @license React | ||
| * react-dom.production.min.js | ||
| * | ||
| * Copyright (c) Facebook, Inc. and its affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| /** | ||
| * @license React | ||
| * react-is.production.min.js | ||
| * | ||
| * Copyright (c) Facebook, Inc. and its affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| /** | ||
| * @license React | ||
| * react-reconciler-constants.production.min.js | ||
| * | ||
| * Copyright (c) Facebook, Inc. and its affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| /** | ||
| * @license React | ||
| * react-reconciler.production.min.js | ||
| * | ||
| * Copyright (c) Facebook, Inc. and its affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| /** | ||
| * @license React | ||
| * react.production.min.js | ||
| * | ||
| * Copyright (c) Facebook, Inc. and its affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| /** | ||
| * @license React | ||
| * scheduler.production.min.js | ||
| * | ||
| * Copyright (c) Facebook, Inc. and its affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| /** @license React v16.13.1 | ||
| * react-is.production.min.js | ||
| * | ||
| * Copyright (c) Facebook, Inc. and its affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,10 @@ | ||
| /* | ||
| object-assign | ||
| (c) Sindre Sorhus | ||
| @license MIT | ||
| */ | ||
|
|
||
| /*! | ||
| * Determine if an object is a Buffer | ||
| * | ||
| * @author Feross Aboukhadijeh <https://feross.org> | ||
| * @license MIT | ||
| */ | ||
|
|
||
| /*! | ||
| * The buffer module from node.js, for the browser. | ||
| * | ||
| * @author Feross Aboukhadijeh <[email protected]> <http://feross.org> | ||
| * @license MIT | ||
| */ | ||
|
|
||
| /*! | ||
| * The buffer module from node.js, for the browser. | ||
| * | ||
|
|
@@ -47,28 +34,10 @@ object-assign | |
| * MIT Licensed | ||
| */ | ||
|
|
||
| /*! | ||
| * focus-trap 7.1.0 | ||
| * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE | ||
| */ | ||
|
|
||
| /*! | ||
| * tabbable 6.0.1 | ||
| * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE | ||
| */ | ||
|
|
||
| /*! @license DOMPurify 2.4.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.3/LICENSE */ | ||
|
|
||
| /*! For license information please see NcModal.js.LICENSE.txt */ | ||
|
|
||
| /*! For license information please see isFullscreen.js.LICENSE.txt */ | ||
|
|
||
| /*! Hammer.JS - v2.0.7 - 2016-04-22 | ||
| * http://hammerjs.github.io/ | ||
| * | ||
| * Copyright (c) 2016 Jorik Tangelder; | ||
| * Licensed under the MIT license */ | ||
|
|
||
| /*! https://mths.be/base64 v1.0.0 by @mathias | MIT license */ | ||
|
|
||
| /*! https://mths.be/he v1.2.0 by @mathias | MIT license */ | ||
|
|
@@ -121,79 +90,10 @@ object-assign | |
| * | ||
| */ | ||
|
|
||
| /** | ||
| * @license React | ||
| * react-dom.production.min.js | ||
| * | ||
| * Copyright (c) Facebook, Inc. and its affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| /** | ||
| * @license React | ||
| * react-is.production.min.js | ||
| * | ||
| * Copyright (c) Facebook, Inc. and its affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| /** | ||
| * @license React | ||
| * react-reconciler-constants.production.min.js | ||
| * | ||
| * Copyright (c) Facebook, Inc. and its affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| /** | ||
| * @license React | ||
| * react-reconciler.production.min.js | ||
| * | ||
| * Copyright (c) Facebook, Inc. and its affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| /** | ||
| * @license React | ||
| * react.production.min.js | ||
| * | ||
| * Copyright (c) Facebook, Inc. and its affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| /** | ||
| * @license React | ||
| * scheduler.production.min.js | ||
| * | ||
| * Copyright (c) Facebook, Inc. and its affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| /** | ||
| * @license nested-property https://github.com/cosmosio/nested-property | ||
| * | ||
| * The MIT License (MIT) | ||
| * | ||
| * Copyright (c) 2014-2020 Olivier Scherrer <[email protected]> | ||
| */ | ||
|
|
||
| /** @license React v16.13.1 | ||
| * react-is.production.min.js | ||
| * | ||
| * Copyright (c) Facebook, Inc. and its affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not fond of lazy loading components that are always included. We don't gain anything but a bit more weight and network usage :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your call; I'd disagree though. The user preceivable performance is primarily due to JS (a) loading time and (b) parsing time. Splitting up the components bundle is faster on both counts. Since the bundle is prefetched and cached, the user can never know about the second request behind the scenes when the viewer is actually opened. In that sense, it's not really lazy loading, but just splitting up parsing and compilation of the critical and non-critical parts (since it all happens on the UI thread). Also the total size remains exactly the same as before, so no extra weight (note I'm looking at
statsize, notparsed).Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is not the case Webpack does not preload the js, it will load them on demand.
If you're on slow network, it can adds up quite a lot :)
Example given: 1.46s to wait for the viewer to load on 4G.

Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you need to specify the
webpackPrefetchand/orwebpackPreloadmagic comment(s) to enable preloading. If that's not working then it's a bug maybe or prefetching is broken somehow.https://webpack.js.org/guides/code-splitting/#prefetchingpreloading-modules
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work for me. If you turn on
Disable Cachein the JS console then it disables prefetching; could be related to that. The above is with a cold cache in incognito.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope even with cache disabled 🤔
Component, plyr or editor are loaded after the viewer is opened.
I'm also ok merging this, and we can always see later how it goes 🤷
But I kind of would like a more wider discussion on async components, so we can all decide to go the same direction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you be up to create a thread on https://github.com/nextcloud/standards/issues with your already impressive graphs and data to show the benefits/disadvantages and how-to of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant it wont work with cache disabled 😅. But if it wasn't disabled earlier then definitely something is off 🤔
Sounds good 👍🏻
Will do. Never knew about this repo. I think most of the overhead is coming from
nextcloud-vueat this point; desperately need tree shaking in there. If that can be fixed then lazy loading components would be pointless to begin with (happy dance).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is on purpose, a bit more discrete to not become the place to discuss any thoughts. I think important topics like those should indeed be brought up there 👍