Closed clshortfuse closed 3 years ago
I realized that Chrome will not emit this as a warning if the code is executing in the beforeunload
block.
Thus, I think it's reasonable to extend this as well to the DOMContentLoaded
block.
I'm not sure why Chrome does that, but that's not a good enough reason to change the standard here. Duplicating this into #20.
So, I'm dealing with an issue with bridging older browsers with the new
manifest.json
spec. Due to the way the pages are served,manifest.json
is served based on certain server criteria (hostname) whileindex.html
is a static file from a CDN.Basically, before the UI events start, and any interaction is possible, I use a
prerender.js
script in<head>
to style the document before it's rendered. This could include things like setting different content header padding if the page is rendered as an iOS PWA. Also, I use this pre-render state to set some colors based onprefers-color-scheme:dark
.Some properties I want to grab straight from
manifest.json
. This means it has to be intentionally synchronous. For example, let's say I want to style thebackground-color
of the document (<html>
) to be the same as what's inmanifest.json
. Let's say I have the color as#000
(black). When a PWA loads, it will load a black background, but, if I don't use block the render before changing thebackground-color
in<html>
and, instead do this asynchronously, then the background will flash white (browser default), and then go black.Here's some short snippets of this configuration:
manifest.json:
index.html:
prerender.js
I will add, I already have a service worker in place to serve
manifest.json
from cache, so ideally speaking, there's as little load-up time lag as possible here. (I'd imagine first fetch could experience a slight uptick in delay, but I could always add a check to see if the application is running as a PWA before doing the synchronous request.)Right now, I'm wary about using the synchronous request because of the deprecated nature. The alternative I currently have is rewriting the
index.html
file, which complicates the back-end.