Small preload script after document load but before page load
I'm trying to port the theme toggle from tailwindcss.com to Solid.js. I'm getting stuck at this part. The following script:
needs to load after the base document loads in order to read localstorage but before the page elements load to prevent a theme change flash. (See the tailwind implementation https://github.com/tailwindlabs/tailwindcss.com/blob/master/src/pages/_document.js)
I tried adding a script inside the
Head
tags from Solid.js like this:
But it didn't work and I got no log in the console.
Could anyone point me to the direction to add a custom script at this point in the page render?2 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Browser outputs:
But nothing in the console. I'll try it without the quotes as that should work.
Adding it directly between script tags causes syntax errors from adding logic JS inside JSX.
I got it working. My console defaulted to errors only.