-
Notifications
You must be signed in to change notification settings - Fork 920
Description
Please verify these steps before filing an issue, and check them off as you go
- The relevant native JavascriptEngineSwitcher library packages are installed (such as
JavaScriptEngineSwitcher.V8.Native.win-x64
) - The VC++ 2017 runtime is installed (I'm not sure, running under Linux)
- The value of
SetUseReact
andSetUseBabel
is correct inReactConfig.cs
orStartup.cs
- I've looked at the sample projects in this repo to verify that my app is configured correctly
I'm using these library versions:
All the latest and greatest things. (Recently updated all packages)
node
: Is node a dependency? Isn't ChakraCore what executes the JS?
Runtime environment:
- OS: (Mac, Windows, Linux flavor. Include 32-bit/64-bit and version): Arch Linux 64 bit
- .NET Framework or .NET Core Version: dotnet core 2.2.105
Steps to reproduce
I don't have a minimal reproducible example, I'm unsure if it is necessary as trying to build one will likely be a pain and the issue itself is probably straight-forward.
I outline the issue with some rough numbers here.
Long story short, calling @Html.ReactInitJavaScript()
causes a significant performance burden even if there are no React components on the page. This is likely due to the fact that my JavaScript bundle is pretty big, and even node takes a while to go through it:
$ time node wwwroot/js/server.js
node wwwroot/js/server.js 0.45s user 0.04s system 105% cpu 0.461 total
My guess is that calling ReactInitJavaScript()
causes the bundle to be loaded even if it is not necessary which raises two issues for me:
-
Imho, the bundle should not be loaded if there are no components to hydrate (Having client-only components on the page still does not require the server to load the bundle on its end).
-
I don't see why the bundle needs to be loaded on every page load. Would it possible to load it once, precompile it and then use the precompiled javascript for each pageload instead of redoing it every time?