今日已更新 240 条资讯 | 累计 22430 条内容
关于我们

Loading custom themes, standard/recommend method?

/u/Ok-Weakness-3206 2026年05月29日 09:17 3 次阅读 来源:Reddit r/webdev

When loading custom themes made by the user & stored somewhere for example local storage, I assume the flow is: 1-Read theme data from storage 2-Flatten theme & generate CSS text 3-Dynamically inject it as a style to the document, os use cssom to add sheets 4-Use [data-theme="custom1...n"] to switch themes Or Have a single placeholder [data-theme="slot"]{} In your static CSS, just read the user selected theme only, flatten, loop over variables & use cssom set property to set the values of tge slot style to those of the theme, & use data-tgeme=slot to activate it, & when the user selects another custom theme load it the same way using cssom & so on & so on, basically injecting a style css vs cssom adoptsheet (which I think has/had? A bug in FF), & load all/many (maybe lazy load), or swap in & out in a static pre-defined css style slot? submitted by /u/Ok-Weakness-3206 [link] [留言]

本文内容来源于互联网,版权归原作者所有
查看原文