Fix for theme switcher
Posted: 2024-09-29 16:02
Anyone who notices flickering with the theme switcher can use this fix in header-extras.php. It loads the themes before any flickering occurs.
<script>
(function() {
var theme = localStorage.getItem('theme') || 'light.css'; // Default ist Light Theme
var prePath = <?php echo json_encode(PREPEND_PATH); ?>;
if(theme) {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.href = prePath + 'resources/initializr/css/' + theme;
document.head.appendChild(link);
}
})();
</script>