Skip to content
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 loading of application areas #5465

Closed
danroth27 opened this issue Jan 25, 2018 · 44 comments
Closed

Lazy loading of application areas #5465

danroth27 opened this issue Jan 25, 2018 · 44 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components Components Big Rock This issue tracks a big effort which can span multiple issues Done This issue has been fixed enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-blazor-lazy-loading Issues related to adding support for lazy-loading in Blazor feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly

Comments

@danroth27
Copy link
Member

No description provided.

@ManfredLange
Copy link

ManfredLange commented Mar 29, 2018

@danroth27 Do you already have a few more details available for how this might work on a conceptual level? E.g. is it envisioned that each lazy-loaded area could be in a separate project/assembly?

I'm always interested in scalability beyond the typical demo projects used at conferences and in tutorials... ;-)

@ManfredLange
Copy link

And another aspect that I believe is of interest to people with existing systems: Is there a way to support a hybrid solution, e.g. an ASP.NET MVC application with some parts implemented using Blazor?

Is this the wrong question and/or does this warrant creating a separate issue?

Perhaps I'm asking to fly to the next galaxy while you guys are trying to just get launched into space in the first place....

@danroth27
Copy link
Member Author

danroth27 commented Mar 29, 2018

@ManfredLange Nothing to share on the design for lazy loading quite yet.

As for ASP.NET MVC, you can use Blazor with any backend that you'd like including non-.NET back ends like Java, JavaScript, PHP, etc, although we make it particularly easy to use Blazor with ASP.NET Core. However, Blazor today takes full ownership of the app and the DOM, so you can't really use MVC to render some HTML on the server and then use Blazor to manipulate the DOM on the client. We are however looking at server-side pre-rendering support for Blazor.

@mungojam
Copy link

mungojam commented May 5, 2018

@danroth27 link above broken. here's the fixed version server-side pre-rendering, I wish GitHub let you do it the way you tried though. You have to put [24] in brackets rather than [#24]

@danroth27
Copy link
Member Author

@mungojam Thanks! Fixed

@ghost
Copy link

ghost commented May 21, 2018

@danroth27
I am not sure, but does it means that Lazy loading will solve this kind of problem?
Can it be coupled with "Mozilla HACKS" about WebAssembly?

@danroth27
Copy link
Member Author

@ckams Lazy loading is about being able to break your Blazor app up into multiple areas that can be loaded independently. It's Blazor specific, so not related to ASP.NET Core MVC and server-side rendering. You do get the perf benefits of WebAssembly in the browser.

@ghost
Copy link

ghost commented May 21, 2018

@danroth27
I'm not sure I understand. Sorry :s
Is Lazy loading like Application Parts?
Can Lazy loading be used to load multiple areas in WebAssembly from server-side?

@danroth27
Copy link
Member Author

Is Lazy loading like Application Parts?

Nope

Can Lazy loading be used to load multiple areas in WebAssembly from server-side?

Yes, lazy loading allows you to load different areas of your app client-side from the server as needed. It's similar to lazy loading in frameworks like Angular or React.

@abhishekgoenka
Copy link

I don't see target release. Any idea in which release this feature will be available?

@danroth27
Copy link
Member Author

@abhishekgoenka Sorry, but we don't know when this feature will land quite yet.

@etmendz
Copy link

etmendz commented Jun 13, 2018

I'm imagining two levels of lazy loading: page level and component level. This will allow the Blazor team to deliver in phases, whichever is easier first (perhaps page level?).

At page level, the entire page is lazy loaded. Thus, in an app, a page's assembly is only loaded to the browser until the user clicks on the page's link. A page would have to be declared as lazy (ex. @lazy "appname.pagename.wasm").

At component level, the component can be declared @lazy "appname.componentname.wasm". In this sense, the component's assembly will be loaded only when the page that needs it is loaded.

Thus, the @lazy directive can be used by the engine to generate different wasm's that can be "plugged in" to the client at runtime upon request (via page and/or component that needs it). I'm thinking WebAssembly's dynamic linking comes to play here (if I'm understanding it correctly)? Or perhaps Blazor will provide the mechanism to allow it?

@hokusp
Copy link

hokusp commented Sep 4, 2018

@danroth27 would it be possible to get any news regarding ETA of lazy loading?

@danroth27
Copy link
Member Author

@hokusp Unfortunately there isn't any news to share at this point. This feature is on our backlog, but we don't expect to get to it any time soon. Our current thinking is that Lazy Loading is not critical for shipping Blazor v1.0. We still want to support it though, and we expect it would ship in a follow on release.

To help us ensure that we are prioritizing this feature correctly, it would be great if folks could share with us more details on how you expect to use this feature and why it's important for your scenarios.

@bmsantos
Copy link

bmsantos commented Sep 4, 2018

Just because Dan asked 👍

In my opinion, Lazy Loading is essential for Blazor to be able to provide a good support for PWAs and a faster web experience in general.

My use case for lazy loading is simply that any page containing its most usable components should be able to be presented to the user within a max of 2 seconds from first visiting the site. This means that both pages and components should be able to be identified as lazy-loaded. Along with lazy loading a page, it would be great if an already loaded page could hint on the next page/components to be loaded and like this triggering a pre-fetching or nav pre-loading mechanism. PWAs can use Service Workers to do pre-fetching but that would not play nicely with Blazor app if no APIs are provided to facilitate it through Blazor.

@hokusp
Copy link

hokusp commented Sep 4, 2018

For my current project, it would be great if I could load Blazor components as independent modules.
I have a website where different modes will be added over time and those modes should not be coupled to the "mainproject", it should be possible that different independent people develop them and that they can be added to the site without redeploying the whole site. I imagine it a bit like an API controller: There is a request to the server /GetAppMode("identifier") and it then loads the module "identifier" and returns it to the client.

@aspnet-hello aspnet-hello transferred this issue from dotnet/blazor Dec 17, 2018
@aspnet-hello aspnet-hello added this to the Backlog milestone Dec 17, 2018
@aspnet-hello aspnet-hello added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one area-blazor Includes: Blazor, Razor Components labels Dec 17, 2018
@isc30
Copy link

isc30 commented Apr 16, 2019

As for lazy loading, lazy dlls (library projects in general) should be the easiest ones to implement.
With this approach, splitting the app in multiple assemblies will simply mean that a request for the dll is made the moment it's required, not before. Then, you could use standard .NET functions like GetAssemblies, GetReferencedAssemblies, etc to know which assemblies (modules) are already loaded.

I don't know a lot about the implementation in this area, sorry if what I'm saying doesn't make sense.

@mkArtakMSFT mkArtakMSFT removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels May 9, 2019
@ghost
Copy link

ghost commented Jun 7, 2019

This is one of the key must-have feature that is missing and keeping us away from adapting Blazor. The concept of representing Areas (https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/areas?view=aspnetcore-2.2) as lazy-load modules would be a good approach. Until this feature is added, it is hard to consider Blazor for medium to large size enterprise applications.

Please consider this as a priority feature.

@ghost
Copy link

ghost commented Jun 21, 2019

@danroth27 are there any updates on this?

@AmarjeetBanwait
Copy link

@danroth27 Will issue (11212) Nested Routing In Blazor be fixed as part of this ?

@captainsafia
Copy link
Member

@AmarjeetBanwait Not really. I'd recommend adding any scenarios/thumbs-up you have on the original issue for nested routes.

@captainsafia captainsafia added feature-blazor-lazy-loading Issues related to adding support for lazy-loading in Blazor and removed Needs: Design This issue requires design work before implementating. Working labels Jun 8, 2020
@sbwalker
Copy link

Oqtane ( https://github.com/oqtane/oqtane.framework ) is a modular framework built on Blazor and it already supports dynamic loading of "modules" created as razor class libraries ( including dealing with CSS and JS loading concerns ). However the current challenge we encountered with lazy loading is not related to dynamically loading assemblies or instantiating razor components... it is related to moving beyond "hello world" scenarios and creating a real world data-centric client/server plug-in module. A data-centric client/server module will have a Web API Controller which the razor components will call to retrieve data from the server. However it appears that the only way to load a Web API Controller dynamically is during Startup using mvcBuilder.PartManager.ApplicationParts.Add(part); This is an issue for lazy loading as it means that these assemblies must all be identified and loaded during startup and cannot be loaded on demand. Will it be possible in MVC 5.0 to dynamically add ApplicationParts outside of Startup?

@captainsafia captainsafia reopened this Jul 1, 2020
@ghost ghost added Done This issue has been fixed and removed Working labels Jul 29, 2020
@captainsafia
Copy link
Member

Thanks for participating in this thread everyone!

We'll be shipping support for lazy-loading as part of the upcoming preview8 release. Some follow-ups will be shipped in rc1, too. Once preview8 ships, you'll find docs on lazy-loading in Blazor at docs.microsoft.com.

Looking forward to hearing your feedback on the feature!

@Dennis-Petrov
Copy link

Dennis-Petrov commented Jul 31, 2020

@captainsafia, when preview 8 will be released?

@boukenka
Copy link

@Dennis-Petrov According to the Milestones section, it is scheduled for August 20, 2020.

@ghost ghost locked as resolved and limited conversation to collaborators Sep 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components Components Big Rock This issue tracks a big effort which can span multiple issues Done This issue has been fixed enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-blazor-lazy-loading Issues related to adding support for lazy-loading in Blazor feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly
Projects
None yet
Development

No branches or pull requests