0

I asked this on aspnetcore GH but it seems like a quite dead forum so I'm trying my luck here...

We just migrated our .NET 6 code base to .NET 8 and I am familiarizing myself with what we can do in blazor with the new additions from .NET 7 and 8. We are running Blazor WASM Standalone btw.

Earlier we used IJsInProcessRuntime and IJsUnmarshalledRuntime (or whatever it is called). The latter is now deprecated in .NET 7 and we have been blessed with the new [JSImport]/[JSExport] API. My question is, since IJSInProcessRuntime is not deprecated, which one is the better option, JSImport or IJsInProcessRuntime? Performance wise. One thing I have noticed is that I don't think we can call functions on JS classes using JSImport, like we can with IJsInProcessRuntime and a JSObjectReference.

Again, we are on WASM only, so we can use sync only calls as much as possible.

For Unmarshalled calls I have obviously migrated to [JSImport] but what about marshalled ones? Are there any performance benefits in switching form IJsInProcessRuntime to [JSImport]?

1 Answer 1

-1

The choice between IJSInProcessRuntime and JSInterop depends on whether you are working with in-process or out-of-process hosting models.

IJSInProcessRuntime (In-Process Model): It is used when the application is hosted in-process with the ASP.NET Core server. The JavaScript interop calls are executed on the same thread as the .NET code. It is efficient for medium size applications with minimal JavaScript interop needs.

JSInterop (Out-of-Process Model): It is used when the application is hosted out-of-process (WebAssembly). The JavaScript interop calls are handled by a separate JavaScript runtime running in the browser. It is suitable for applications where more complex interactions with JavaScript are needed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.