I'm on @solidjs/start 0.7.7 and trying to add an onload="this.onload=null;this.rel='stylesheet'" on a link tag. The purpose is more widely explained here.
Problem with this approach is that typescript keeps shouting Type 'string' is not assignable to type 'EventHandlerUnion<HTMLLinkElement, Event> | undefined'. So I rewrote the single liner above to the following:
<link
...
onLoad={function (this: HTMLLinkElement) {
console.log("I was run")
this.onload = null
this.rel = "stylesheet"
}}
/>
And I don't see the console.log anywhere. I checked on the console tab, the terminal I ran "pnpm dev" on... nothing
How should I handle this? I'd like to keep onload="this.onload=null;this.rel='stylesheet'", or accept any alternatives that work
web.dev
Learn how to defer non-critical CSS with the goal of optimizing the Critical Rendering Path, and improving First Contentful Paint (FCP).