Giter Club home page Giter Club logo

phpwee-php-minifier's Introduction

phpwee-php-minifier

PHPWee is an inline PHP minifier for web resources. It lets you minify HTML4, HTML5, XHTML, CSS and JavaScript files in a single line of code.

The best bit is its free and open source under the BSD license.

Installing PHPWee

Installing PHPWee should only take a minute. Here are you 3 choices:

You can include all the necessary classes by simply including the phpwee-php-minifier/phpwee.php file.

require_once ("phpwee-php-minifier/phpwee.php");

Using PHPWee

How to compress HTML:

$minified_html = PHPWee\Minify::html($any_html);

This automatically compresses all inline scripts and stylesheets within the HTML document. Apply a 'data-no-min' attribute to a script or style to exclude it from minification.

How to compress CSS:

$minified_css = PHPWee\Minify::css($any_css);

How to compress JS:

$minified_js = PHPWee\Minify::js($any_js);

Spelling out out:

require_once ("phpwee-php-minifier/phpwee.php");

$html = file_get_contents("http://en.wikipedia.org/wiki/Minification_%28programming%29");
$minified_html = PHPWee\Minify::html($html);
// a 9.38% performance boost - in 3 lines of code!!

There are working examples in the /examples folder of the package.

PHPWee Performance

  • The compression ratio are typically 5-20% for HTML
  • The compression ratio are typically 5-30% for CSS
  • The compression ratio are typically 5-30% for JavaScript

Even highly optimized sites such as wikipedia.com, github.com and W3Schools.com can reduce the size of their HTML payload using PHPWee html compression.

Performance Graph

Who Makes PHPWee ?

The PHPWee HTML compression technology is totally new. It actually parses HTML documents and removes unneeded spaces and verbosity without changing meaning in any way. The output is generally at least as W3C compliant as the input.

The Css compressor is built upon the CssMin package by Joe Scylla [email protected]. The JavaScript compressor is built upon Douglas Crockford's JSMin.

PHPWee Purpose

PHPWee is built and maintained by http://searchturbine.com as part of their 20% codeshare policy. They can be contacted at [email protected]

PHPWee was designed as a pre-CDN optimizer for the searchturbine.com website - which is hosted on Github pages. It currently offers about 22% compression site-wide - and is used in the deployment process.

This technology would is ideally placed to be used in deployment scripts for websites, and would also fair wall as part of a CDN architecture.

PHPWee Improvements

  • We are relatively new to Composer - and welcome input on package improvements.
  • Removing default values from html tags should reduce HTML file size
  • Allowing HTML fragments rather than whole documents would be ideal.

We "eat our own dog-food". We will be using this package to optimize http://searchturbine.com - and will publish all results, insights and improvements.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.