Skip to content

Explore removing inline module script for Blazor Wasm #36805

Closed
@TanayParikh

Description

@TanayParikh

// Due to a strange behavior in macOS Catalina, we have to delay loading the WebAssembly files
// until after it finishes evaluating a <script> element that assigns a value to window.Module.
// This may be fixed in a later version of macOS/iOS, or even if not it may be possible to reduce
// this to a smaller workaround.
function addGlobalModuleScriptTagsToDocument(callback: () => void) {
const scriptElem = document.createElement('script');
// This pollutes global but is needed so it can be called from the script.
// The callback is put in the global scope so that it can be run after the script is loaded.
// onload cannot be used in this case for non-file scripts.
window['__wasmmodulecallback__'] = callback;
scriptElem.text = 'var Module; window.__wasmmodulecallback__(); delete window.__wasmmodulecallback__;';
document.body.appendChild(scriptElem);
}

Metadata

Metadata

Assignees

Labels

area-blazorIncludes: Blazor, Razor Componentscost: SWill take up to 2 days to completefeature-blazor-wasmThis issue is related to and / or impacts Blazor WebAssemblytask

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions