Commit 958cc163 authored by Deimos's avatar Deimos

Try to make JS execute earlier

Since the Javascript causes the site's theme to change, if it executes
slowly we can see the site load as white initially before it changes.
This should make it so that it executes earlier - placing the script tag
as the first thing inside the body, and also taking the theme-switch out
of a window.onload event so that it will run immediately.
parent d4b4b465
......@@ -12,9 +12,7 @@ function getCookie(cookieName) {
return null;
}
window.onload = function() {
var theme = getCookie("theme");
if (theme) {
document.body.classList.add("theme-"+theme);
}
var theme = getCookie("theme");
if (theme) {
document.body.classList.add("theme-"+theme);
}
......@@ -16,6 +16,7 @@
<title>{% block title %}{% endblock %}</title>
</head>
<body class="static-site">
<script src="{{ SITEURL }}/theme/js/tildes-static-sites.js"></script>
<header id="site-header">
{% block header %}{% endblock %}
</header>
......@@ -36,6 +37,5 @@
</ul>
</footer>
<script src="{{ SITEURL }}/theme/js/tildes-static-sites.js"></script>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment