[Vuejs]-Do async components speed up load time?

3đź‘Ť

Importing dynamically will generate a new file, and this new file will only be downloaded when the user goes to that specific page, not when the user goes to /.

That increases load speed and decreases the bytes that the user has to download at the moment one access your site.

👤PlayMa256

1đź‘Ť

For all intents and purposes…probably not.

With today’s modern devices, browsers, and Internet access, that component would have to be pretty significant in order to provide a speedup overall to page load. If it’s just markup and code, I’d have a hard time believing that one component would even come close to approaching say, 700Kb in size (especially if minified and compressed). In all but the worst Internet connectivity, the browser is going to handle this with no problem at all, especially if the component is include in the main bundle for the site.

However, if your component does some heavy computational work upon arrival, then maybe there would be a speedup to loading it async (as the browser can “get on with” loading the page while waiting for the modal to arrive).

However however, most browsers only allow a number of XHR requests running to a single domain at a time (I think Chrome is 4 by default). Lazy loading a file would mean the requests made by the page itself take priority, but having more files to load over multiple requests rather than lumped into one may be overall slower.

However however however, browsers are excellent at caching these requests, so subsequent visits to your site probably wouldn’t have this problem to consider.

Lazy loading modules really provides a speedup when you are able to lazy load entire sections of your site only when the user needs to access them, like on routes.

The final however, though, is that it’s good practice to not burden browsers and mobile devices with needless bloat, and while lazy loading that module may not have a noticeable speed difference, it may overall be a decent idea depending on your needs and when you load it. If a visitor never needs to view the modal, and you load the modal when it’s needed…there’s a lot to consider, as that may cause a delayed UI but be better for an overall greater percent of your users.

If you’re trying to make your site more accessible to those with poor Internet, and you know the modal will be used frequently, it’d be probably better to load it with the page because it’s part of page functionality.

👤joh04667

Leave a comment