0

I am using this for async loading the CSS file:

<link rel="preload" href="style.css" as="style" onload="this.rel='stylesheet'">

, but the event doesn't bind in Firefox. In Chrome works fine and preload is changed to stylesheet. In FF stays the same.

I have tried with onload="console.log(90)"> and it binds in Chrome, but no in FF.

gdfgdfg
  • 3,181
  • 7
  • 37
  • 83

1 Answers1

2

The preload specification is only an Editor's Draft. It isn't standard. It should be considered experimental and not for production use.

Firefox doesn't support it as standard (although you can turn it on in the browser's settings if you want to test its implementation).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • I know it doesn't support. If you check the code you will see, that it uses onload event to change it to `stylesheet`, but this onload event doesn't bind in FF. This is what I am asking. – gdfgdfg Apr 20 '20 at 11:26
  • 1
    @gdfgdfg — It doesn't support preload. So it doesn't load it. Since it never loads it, the onload event won't fire. – Quentin Apr 20 '20 at 11:27
  • Ok, but why this works in Chrome ? Also, https://stackoverflow.com/a/46750893/5849229 – gdfgdfg Apr 20 '20 at 11:41
  • 1
    Because Chrome **does** support preload! And the answer you link to **says** that it won't work in Firefox! – Quentin Apr 20 '20 at 11:44
  • hm ok thanks. I was confused that it works on Chrome and forgot actually what onload means :) . – gdfgdfg Apr 20 '20 at 12:26