Cross-posting from <#C02B3PECK6E|> as I'm not sure...
# multiplatform
s
Cross-posting from #C02B3PECK6E as I'm not sure where this question belongs: I currently made a website using the WASM export and it works for all clients, except for iOS below
18.2
. This is related to the fact that they only introduced support for
WASM
GC with their recent os update. To bypass this there is the option of exporting the whole project in JS, but I would prefer to stay in
WASM
. Is there somehow an option to detect the browser of the user doesn't support
WASM
GC and redirect him to a different index.html with an explanation or something?
solved 1
h
You can always show a html element containing the error and hide it using WASM.
1
s
Ah that's quite clever, didn't even consider that scenario. I'll give it a shot, thanks!
Works like a charm, thanks! FYI for anyone facing the same: • Modify your
index.html
and add a div in the body like
<div id="wasmgc_support_1">...
• In your app entry point add the following
document.getElementById("wasmgc_support_1")?.remove()
It will show it for a few miliseconds at the start of the page, but it sure beats having clueless users staring at a white page until iOS 18.2 adoption is a bit further
h
A user could also disable JS too
But checking for all required WASM features is quite clever.
s
So for the above solution I would have to define the JS target as well so it could use it as a fallback if I understand right?
h
Well, you could but I would just copy the plain JavaScript code to check the WASM features and not use Kotlin JS at all.
And then load WASM like in the Kotlin conf sample app. You could still use the html error workaround to show a plain html error message if the user disabled JS and WASM.
s
Not completely sure I understand how the mechanism works or what the expected result is though. As I understood it, in this case I would need both the wasmJs build target and the js build target, run their gradle tasks to create the
dist
outputs and then merge these together I suppose? But I assume more adaptations in the code are actually required to get this working no?
h
If you really want to support non WASM browsers, you need a Kotlin JS target too, yes. If you just want to show the user a error message, you don’t need Kotlin JS. But if you want to add a Kotlin/JS target, what’s the point having the WASM target?
s
Right, fair point indeed. Honestly, given the low-prio of the project and the current timeframe of WASM releases I think I'll stick to WASM for now along with the warning. Expect to be able to remove it in a year tops.