Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compress() method to Document #59

Closed
slusarz opened this issue Mar 20, 2013 · 1 comment
Closed

Add compress() method to Document #59

slusarz opened this issue Mar 20, 2013 · 1 comment

Comments

@slusarz
Copy link
Contributor

slusarz commented Mar 20, 2013

For maximum compressibility (i.e. removing all unneeded whitespace and semicolons), might want to add this method to Document:

    public function compress()
    {
        return str_replace(
            array("\n", ' {', ': ', ';}', ', '),
            array('', '{', ':', '}', ','),
            strval($this)
        );
    }

We currently have this in the wrapper object around the Document object, and it seems to work fine on all browsers. At the least, it outputs code that looks very similar to what jquerymobile does to compress their CSS (i.e. taking their CSS -> importing into PHP-CSS-Parser -> strval($document) -> compressing output = output almost identical to the input).

@sabberworm
Copy link
Contributor

This is a duplicate of issue #6 (which, believe it or not) is in the works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants