codealfa/minify
Composer 安装命令:
composer require codealfa/minify
包简介
An extremely fast PHP based minification library for Javascript, CSS, Html and Json scripts using Regex Parsing
README 文档
README
An extremely fast PHP based minification library for Javascript, CSS, Html and Json scripts using Regex Parsing
Installation
Run the following command to use the library in your projects:
composer require codealfa/minify
Basic Usage
You can use any of the minifiers in the following way:
use CodeAlfa\Minify\Js; $sMinifiedJs = Js::optimize($sOriginalJs);
Html Minifier Options
The HTML minifier takes the following options:
cssMinifier(defaultnull): Callback function to minify the contents of in-page<style>elements.jsMinifier(defaultnull): Callback function to minify the contents of in-page<script>elements.jsonMinifier(defaultnull): Callback function to minify the contents of in-page json contents. The Html Minifer will inspect thetypeattribute ofscriptcontents to determine if it's javascript or json.minifyLevel(default0): Determine the minification level of the HTML. Possible values are:0: Runs of whitespace outside elements are reduced to one whitespace, if a line feed is included it will be preserved. (HTML comments are not removed). In-page scripts and styles are minified if callback functions were provided.1: HTML comments are removed, along with whitespaces around block elements. Unnecessary whitespaces inside elements and around attributes are removed.2: Redundant attributes eg.,type="text/javascript"are removed. Quotes are removed from selected attributes if the isHtml5 option is set totrue.
isXhtml(defaultfalse): HTML content treated as XHTML1.0. In-page javascript content with characters that needs escaping in XML will be surrounded by/*<![CDATA[*/and/*]]>*/isHtml5(defaultfalse): If set totruethen whenminifyLevelis set to2, quotes are removed from attibutes if they don't contain characters that necessitates quoting.
Example:
use CodeAlfa\Minify\Html; $aOptions = array( 'cssMinifier' => array('CodeAlfa\Minify\Css', 'optimize'), 'jsMinifier' => array('CodeAlfa\Minify\Js', 'optimize'), 'minifyLevel' => 2, 'isHtml5' => true ); $sMinifiedHtml = Html::optimize($sOriginalHtml, $aOptions);
License
GPL-3.0 or later
codealfa/minify 适用场景与选型建议
codealfa/minify 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 322 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 10 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 codealfa/minify 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 codealfa/minify 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 322
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2020-10-12