PWA Changing Meta Color from load screen

What I’m trying to do:
Change the PWA Meta color of my app, even from the loading screen.

What I’ve tried and what’s not working:
I’ve tried the solution from this thread:

This works, but only after the app has loaded. When the app is still loading, the meta background is still the default color until the page loads and then it uses my color:

<head>
  <meta name="theme-color" content="#ff0d3e" />

  <script defer>
    document
      .querySelector('meta[name="theme-color"]')
      .setAttribute("content", "#ff0d3e");
  </script>
</head>

The theme-color is derived from your app’s colour scheme. It should be whatever the first colour in your theme colour scheme is set to.

2 Likes