1
0

theme-init.js 735 B

12345678910111213141516
  1. /*
  2. * Copyright 2026 Alessandro Chiapparini <sprint_planer_web@chiapparini.org>
  3. * SPDX-License-Identifier: Apache-2.0
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * See the LICENSE file in the project root for the full license text.
  8. */
  9. /* Phase 16: sync theme apply before stylesheet load — avoids FOUC.
  10. Loaded without defer/async from <head>. Reads sp:theme; dark → add class.
  11. Wrapped in try/catch so private-window localStorage denials no-op. */
  12. try {
  13. if (localStorage.getItem('sp:theme') === 'dark') {
  14. document.documentElement.classList.add('dark');
  15. }
  16. } catch (e) { /* localStorage denied — stay light. */ }