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

Feature request - Lazy load objectManager.js #368

Open
jHabjanMXP opened this issue Sep 16, 2024 · 6 comments
Open

Feature request - Lazy load objectManager.js #368

jHabjanMXP opened this issue Sep 16, 2024 · 6 comments

Comments

@jHabjanMXP
Copy link

Hey,

Is there an option to load objectManager.js only when it's needed?

    private readonly Lazy<Task<IJSObjectReference>> _structureModule = new Lazy<Task<IJSObjectReference>>(() => jsRuntime.InvokeAsync<IJSObjectReference>(
    "import", "./...etc...objectManager.js").AsTask());

...
var module = await _structureModule.Value;
await module.InvokeAsync(...
@valentasm1
Copy link
Collaborator

Interesting. Could you show full sample?
Also not sure if it is library resposinbility since this part is manual for anyone. Of course probable in latest blazor it is not de facto.

@jHabjanMXP
Copy link
Author

I don't want to include js script in index.html as I'm using google maps only later in the app and I want my initial load time to be small - I don't want script evaluation to take CPU time.

https://stackoverflow.com/a/67536500/5909875

functions need to be exported for this module to use them though, And in order for module to access other javascript files, you need to import them directly in js file

@jHabjanMXP
Copy link
Author

Created #370

@valentasm1
Copy link
Collaborator

Does it have any meaningful impact? Whats it the main motivation?
Google maps Maps js are not loaded while you navigate to page

@jHabjanMXP
Copy link
Author

Motivation - reduce initial load of js files (reduce network bandwidth and script evaluation)

@valentasm1
Copy link
Collaborator

Do you metrics?
I doubt that 40kb file has any impact. Maybe in other big libraries scenarios.
Dont get me wrong i am not against it. Especially flexible implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants