压缩含有 php、javascript、html 和 css 的网页
我找到了可以单独压缩 html、javascript 和 css 文件的实用程序。但是,假设我有一个名为 homepage.php 的文件,其中 php 位于页面顶部,css 和 javascript 位于页眉中,html 位于正文中,还有更多 php 代码,也许还有更多 javascript。有时,带有 javascript 的块中也可能包含 php(用于将 php 值传输到 javascript)。是否有任何实用程序可以处理压缩此类页面?
检查每个文件、手动将其分解并单独压缩所有内容可能会变得非常乏味。即使只是压缩文件中的 html 和 css 而忽略 javascript 和 php 的东西也会非常有用。无论如何,我的大部分 javascript 都在外部 js 文件中。
I have found utilities that can compress html, javascript, and css files individually. However, lets say I have a file called homepage.php with php at the top of the page, css and javascript in the header, html in the body along with more php code and perhaps some more javascript. Sometimes, the chunks with javascript may also have php in it (for transferring php values to javascript). Are there any utilities that can handle compressing such pages?
Going through every file, breaking it apart manually, and compressing everything individually can get very tedious. Even something that can just compress the html and css in the files and ignore the javascript and php would be extremely useful. Most of my javascript is in external js files anyway.
发布评论
评论(4)
如果这个问题背后的想法是使用更少的带宽,那么我建议您使用 apache 输出过滤器(假设您无论如何都使用 apache 作为网络服务器)。只需使用 ie 过滤所有 PHP 脚本和静态 HTML 页面即可。 mod_deflate,您将使用更少的带宽。
If the idea behind this question is to use less bandwidth, then I suggest you use an apache output filter (assuming that you are using apache as webserver anyway). Just filter all PHP scripts and static HTML pages with ie. mod_deflate, and you'll use less bandwidth.
即使没有工具可以让您一次完成所有小型化,您也可以使用 DOM 轻松实现自动化。只需解析页面并找到所有
和