Settings最適化計画 2025/03/22
Settingsを最適化する
主に最適化するところ
計算量
バンドルサイズ
今回は、主に計算量の最適化を優先する
:has()の最適化
やり方
:hasの左側を詳細化する
直下セレクタを活用する
多少の記述の冗長化は許容する
曖昧なセレクタをできるだけ詳細化する
これによりDOM探索範囲が減る
仕様変更に弱くなるというデメリットがある
使用率が低いCSSを無効化
一旦、minifyなしでbundleして:hasの使用状況を調べる
だん.iconhr.iconをCSSで描画するUserCSS
.line .text > span:has(a.link.icon:is([href$="/icons/hr"], [href$="/icons/hrd"]))
.line .text > span span:has(a.link.icon:is([href$="/icons/hr"], [href$="/icons/hrd"]))
だん.icon文法エラー・警告をIDE風に表示するUserCSS
span:has(> span.deco-\+.deco-_)
このCSSあまり使われてないので消すか
だん.iconセパレーター記法
.line:not(.cursor-line) .deco:has(.deco-\'):has(.deco-_)
&:has(.deco--)
:has(.deco-_)
だん.icon白黒記法
.line:not(.cursor-line) .deco-\#:not(:hover):not(:has(a))
.line:not(.cursor-line) .deco-\#:not(:hover):has(img)
だん.iconネコと和解せよ記法
.line:not(.cursor-line) .deco-\#:not(.deco-\#.deco-\+):has(a:not(.icon))
だん.iconはんこ記法
.line:not(.cursor-line) [class="deco-( deco-)"]:not(:has(img.icon))
.line:not(.cursor-line) [class="deco-( deco-)"]:not(:has(img.icon)) a
グリッチUserCSS
.line:not(.cursor-line) .deco-\+.deco-\#
&:not(.hover):has(img)
削除
都合の悪いサムネイルを非表示にするUserCSS
.stream .page:is([data-title="\3082\307a\3082\307a\7e3a\ff6e\8373\ff78\7e3a?\ff44\7e3a\ff64"]) .line a:has(img)
だん.iconquicksearch候補を見やすくする
ul.dropdown-menu > li.dropdown-item:has(a:focus)
引用記法中で箇条書きするときに行が長いとバレットが独立してしまうのを防ぐCSS
.line .quote:has(.indent-mark)
消しても良さそう
% curl https://scrapbox.io/api/code/villagepump/settings/dist.css | wc
Settings 21881 bytes