-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimization for page load theme-change delay #28
Comments
Thank you my friend. It's a challenge because on one hand, we don't want to block the page loading by the script, on the other hand, we want to apply the theme before page loading... Also, many people instead of using a |
Thank you all. Following Mr. Farukcan's comment, I temporarily added the following code to the <script async crossorigin="anonymous">
var selectedTheme = localStorage.getItem("theme");
if(selectedTheme) {
document.documentElement.setAttribute("data-theme", selectedTheme);
}
</script> |
hi @JieyueCoding it does not work for me i mean, it need to be checked from blank tab each, not from already visited website the glitch is still there can i see your demo, please? |
We must change theme before pageload event to avoid theme changing delay.
Add async attribute. And add this element to
<head>
. It must be first loaded script that no need wait for page load.<script async crossorigin="anonymous" src="./theme-change.js"></script>
Thanks for your library!
The text was updated successfully, but these errors were encountered: