任何只结合 Web 应用程序所需的 css 和 js 的好方法

发布于 2024-11-07 17:50:08 字数 269 浏览 5 评论 0原文

我一直在改进 Web 应用程序前端的结构,并完成了诸如组合和缩小 css/js 文件、版本文件以及构建一些模板之类的工作。然而,我正在查看一些网络工具,它说有大量未使用的 js/css。有什么建议吗 -发现完全必要的代码 - 组合、缩小页面的正确代码并对其进行版本控制 我主要寻找逻辑建议,任何代码示例都会很棒。我专门在 apache 上使用 python、cheetah templates、yui-compressor、modified time for versioning、mod_rewrite 和 gzip

I have been improving the structure of a web app's frontend and have done things like combine and minify css/js files, version files, and building out some templates. However I was looking at some web tools and it is saying there is a ton of unused js/css. Are there any suggestions on
-discovering the completely necessary code
-combining, minifying, and versioning the right code for the page
I am mainly looking for like a logical suggestion any code samples would be great. I am specifically using python, cheetah templates, yui-compressor, modified time for versioning, mod_rewrite and gzip on apache

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅紫色的梦幻 2024-11-14 17:50:08

查看 Dust-Me Selectors Firefox 扩展以简化 CSS:

Dust-Me 选择器是 Firefox
扩展(适用于 v1.5 或更高版本)
查找未使用的 CSS 选择器。

它从所有选择器中提取所有选择器
您所在页面上的样式表
查看,然后分析该页面
看看哪些选择器不是
用过的。然后存储数据,以便
当测试后续页面时,
选择器可以从列表中划掉
当他们遇到时。

您可以单独测试页面,或者
抓取整个网站,然后你就会结束
列出了哪些选择器的配置文件
没有在任何地方使用。

对于 JavaScript,请查看 Google Closure 编译器,它可以计算代码中的相互依赖关系并删除裁员。

闭包编译器是一个工具
让 JavaScript 下载并运行
快点。它是一个真正的编译器
JavaScript。而不是从编译
源语言到机器代码,它
从 JavaScript 编译为更好的
JavaScript。它解析你的 JavaScript,
分析它,删除死代码并
重写并最小化剩下的内容。它
还检查语法、变量
参考文献、类型和警告
常见的 JavaScript 陷阱。

Check out the Dust-Me Selectors Firefox extension for streamlining CSS:

Dust-Me Selectors is a Firefox
extension (for v1.5 or later) that
finds unused CSS selectors.

It extracts all the selectors from all
the stylesheets on the page you're
viewing, then analyzes that page to
see which of those selectors are not
used. The data is then stored so that
when testing subsequent pages,
selectors can be crossed off the list
as they're encountered.

You can test pages individually, or
spider an entire site, and you'll end
up with a profile of which selectors
are not used anywhere.

For JavaScript, take a look at the Google Closure Compiler which can calculate codependencies within your code and remove redundancies.

The Closure Compiler is a tool for
making JavaScript download and run
faster. It is a true compiler for
JavaScript. Instead of compiling from
a source language to machine code, it
compiles from JavaScript to better
JavaScript. It parses your JavaScript,
analyzes it, removes dead code and
rewrites and minimizes what's left. It
also checks syntax, variable
references, and types, and warns about
common JavaScript pitfalls.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文