pub(crate) fn locale_redirection_fallback(
        mut self,
        redirect_url: &str,
        global_state: &TemplateState,
    ) -> Self {
        self.locale = "xx-XX".to_string();

        // We still have to inject the global state, which is unlocalized (see #267)
        let global_state = escape_page_data(&global_state.state.to_string());
        let global_state = format!("window.__PERSEUS_GLOBAL_STATE = `{}`;", global_state);
        self.scripts_before_boundary.push(global_state);

        // We also still have to inject an unlocalized render config
        self.head_after_boundary
            .push("<script src=\".perseus/initial_consts.js\"></script>".to_string());

        // This will be used if JavaScript is completely disabled (it's then the site's
        // responsibility to show a further message)
        let dumb_redirect = format!(
            r#"<noscript>
        <meta http-equiv="refresh" content="0; url={}" />
    </noscript>"#,
            redirect_url
        );

        // This will be used if JS is enabled, but Wasm is disabled or not supported
        // (it's then the site's responsibility to show a further message)
        //
        // Wasm support detector courtesy https://stackoverflow.com/a/47880734
        let js_redirect = format!(
            r#"
        function wasmSupported() {{
            try {{
                if (typeof WebAssembly === "object"
                    && typeof WebAssembly.instantiate === "function") {{
                    const module = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
                    if (module instanceof WebAssembly.Module) {{
                        return new WebAssembly.Instance(module) instanceof WebAssembly.Instance;
                    }}
                }}
            }} catch (e) {{}}
            return false;
        }}

        if (!wasmSupported()) {{
            window.location.replace("{}");
        }}
            "#,
            redirect_url
        );

        self.head_after_boundary.push(dumb_redirect);
        self.scripts_after_boundary.push(js_redirect);
        #[cfg(feature = "preload-wasm-on-redirect")]
        {
            // Interpolate a preload of the Wasm bundle
            // This forces the browser to get the bundle before loading the page, which
            // makes the time users spend on a blank screen much shorter We have
            // no leading `/` here because of the `<base>` interpolation
            // Note that this has to come before the code that actually loads the Wasm
            // bundle The aim of this is to make the time loading increase so
            // that the time blanking decreases
            let wasm_preload = format!(
                r#"<link rel="preload" href="{path_prefix}/.perseus/bundle.wasm" as="fetch" />"#,
                path_prefix = self.path_prefix
            );
            self.head_before_boundary.push(wasm_preload.into());
        }

        self
    }
Interpolates a fallback for locale redirection pages such that, even if
JavaScript is disabled, the user will still be redirected to the default
locale. From there, Perseus' inbuilt progressive enhancement can
occur, but without this a user directed to an unlocalized page with JS
disabled would see a blank screen, which is terrible UX. Note that
this also includes a fallback for if JS is enabled but Wasm is disabled.
Note that the redirect URL is expected to be generated with a path
prefix inbuilt.

This also adds a `__perseus_initial_state` `<div>` in case it's needed
(for Wasm redirections).

Further, this will preload the Wasm binary, making redirection snappier
(but initial load slower), a tradeoff that generally improves UX.
packages/perseus/src/server/html_shell.rs