Discuz!小编 发表于 2026-5-3 09:06:20

网站css太大了,废弃css,废旧css,未使用css太多了,导致网站加载非常卡。怎么优化? New

网站css太大了,废弃css,废旧css,未使用css太多了,导致网站加载非常卡。怎么优化?



我用的是第三方模板,这个模板作者优化太差劲了,原文件css也非常大,好几个都是200~400kb的。也有可能跟我定制有关,因为我模板自身使用的css非常少的。



我看了缓存的css,也非常多,非常大。如下图所示。。



我用覆盖率查了一下,我浏览了常用的20几个页面。综合看了一下,未使用率高达95%。



综上,请问该如何优化?废弃代码太多,每次都全部加载,导致网站加载太卡了,专业程序员是如何优化这些废弃的代码的?














我知道答案 回答被采纳将会获得1 贡献 已有1人回答

KarlMock59 发表于 2026-5-3 09:06:56

怎么才能把废弃的,未使用的css代码删除掉。。找谁?

       

.ce-block {        margin-top: 20px;    margin-bottom: 20px;}.ce-block__content,.ce-toolbar__content {        /* max-width:calc(100% - 50px) */        margin-left: auto;    margin-right: auto;}/** * Plugin styles */.ce-header {position: relative;padding: 1px 0px 1px 15px;margin: 0;line-height: 1.25em;outline: none;margin-bottom: 10px;}.ce-header p,.ce-header div {padding: 0 !important;margin: 0 !important;}.ce-header::before {    content: "";    width: 0;    height: 0;    border-top: 8px solid transparent;    border-bottom: 8px solid transparent;    border-left: 12px solid #155BD5;    position: absolute;    left: 0;    top: 50%;    transform: translateY(-50%);    background-color: transparent;    border-radius: 0;}/** * Styles for Plugin icon in Toolbar */.ce-header__icon {}.ce-header::before {position: absolute;content: attr(data-placeholder);color: #707684;font-weight: normal;display: none;cursor: text;}.ce-header:empty::before {display: block;}.ce-header:empty:focus::before {display: none;}/* FontSize */h1.ce-header {    font-size: 2.0em;}h2.ce-header {    font-size: 1.7em;}h3.ce-header {    font-size: 1.4em;}h4.ce-header {    font-size: 1.15em;}h5.ce-header {    font-size: 0.95em;}h6.ce-header {    font-size: 0.8em;}/* Alignment*/.ce-header--right {text-align: right;}.ce-header--center {text-align: center;}.ce-header--left {text-align: left;}.ce-header--justify {text-align: justify;}.inline-code {background: rgba(250, 239, 240, 0.78);color: #b44437;padding: 3px 4px;border-radius: 5px;margin: 0 1px;font-family: inherit;font-size: 0.86em;font-weight: 500;letter-spacing: 0.3px;}
页: [1]
查看完整版本: 网站css太大了,废弃css,废旧css,未使用css太多了,导致网站加载非常卡。怎么优化? New