我如何避免重新提取残疾的CSS文件
我正在尝试在我的网站上实现“黑暗主题”,目前通过包括2个样式表:
<link rel="stylesheet" type="text/css" href="/flatly.css">
<link rel="stylesheet" type="text/css" href="/darkly.css">
然后将“禁用”属性添加到Darkly CSS链接到Disable/Enable Dark主题。
这确实有效,但是每次我单击“启用”按钮时,提出了新的网络请求,以使Dark.css文件下载,这会导致恢复较小的滞后。
有人知道我如何解决这个问题吗?
I am trying to implement dark theme on my website and I currently do it by including 2 style sheets:
<link rel="stylesheet" type="text/css" href="/flatly.css">
<link rel="stylesheet" type="text/css" href="/darkly.css">
and then adding/removing the "disabled" attribute to the darkly css link to disable/enable dark theme.
This does work, but every time I click the enable button a new network request is made to download the darkly.css file, which causes a small lag in rerendering.
Does anyone know how I can get around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查您添加和删除残疾人属性的方式。使用纯JS,不要重新提取。
有这个小小的 gist and gist运行此过程。
Check the way you are adding and removing the disabled property. Using pure JS, it's not to be re-fetching.
There's this little gist running this process.