Coder Social home page Coder Social logo

gmt-html-minify's Introduction

HTML Minify

HTML Minify is a plugin for WordPress that compresses the HTML output to reduce file size and improve performance. It's forked from a script by DVS.

Download HTML Minify

Getting Started

Getting started with HTML Minify is as simple as installing a plugin:

  1. Upload the html-minify folder to the /wp-content/plugins/ directory.
  2. Activate the plugin through the Plugins menu in WordPress.

And that's it, you're done. Nice work! You change what gets minified under "Settings" in the Admin Dashboard.

It's recommended that you also install the GitHub Updater plugin to get automattic updates.

Known Issues

It's been reported that data URIs may break the minifier. This has not been consistently duplicated, nor is their a fix available, but is something to be aware of.

How to Contribute

Please read the Contribution Guidelines.

License

The code is available under the MIT License.

gmt-html-minify's People

Contributors

cferdinandi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gmt-html-minify's Issues

Base64 inline image kills the plugin

Hi Chris

Great plugin!

I tried to add this to a post with base 64 inline images but it killed the output.

Sample base64 data (also be used with audio and video binaries):
<img src="data:image/jpeg;base64,{IMAGE DATA HERE (braces not included)}โ€ alt="name" width="XXX" class="alignleft size-full wp-image-xxx">

Sample base64 data: 0dv4X1oaaWoFc30BEaXvSHWwJGsH9aVtfnpalF508KBW

There is nothing to minify here.

Is there a simple way to add to your code to ignore everything inside img, audio and video tags? There are no "<" or ">" inside base64 data but there are "/".

I see this:
if ($tag == 'pre' || $tag == 'textarea') {
$raw_tag = $tag;
}
else if ($tag == '/pre' || $tag == '/textarea') {
$raw_tag = false;
}

But these media tags don't have closing tags, only brackets.

I also saw in your code regular expressions for CSS and Javascript, but they also have closing tags.

I was thinking of 2 options:

  1. A regex that switches to raw from
    For example to add in the $pattern: /<(?img).*>
  2. Add an exclusion similar to 'pre' for 'figure'

What would you suggest?

Cheers
Mike

JS compression when there is CDATA inline : update to make it work ;)

Now the plugin make site crash when there is a CDATA balise in the source code when we want to minify JS

there is a modification to do for make it work :
Add those line :
$str = str_replace("//", '', $str);

in

protected function removeWhiteSpace($str) { ...

like that :

protected function removeWhiteSpace($str)
{
    $str = str_replace("\t", ' ', $str);
    $str = str_replace("\n",  '', $str);
    $str = str_replace("\r",  '', $str);
    $str = str_replace("//<![CDATA[",  '', $str);
    $str = str_replace("//]]>",  '', $str);

    while (stristr($str, '  '))
    {
        $str = str_replace('  ', ' ', $str);
    }

    return $str;

By the way it will be a good thing to do : add a checkbox in admin to activate or not the result of the compression

protected function bottomComment($raw, $compressed) {
$raw = strlen($raw);
$compressed = strlen($compressed);
$savings = ($raw-$compressed) / $raw * 100;
$savings = round($savings, 2);
return '';
}

$this->html .= "\n" . $this->bottomComment($html, $this->html);

Problem with long JSON Strings

Hi,

I have a very long (1228892 characters). Minify just can't handle that. I get no HTML after this.

I can't really see where the problem is.

Please fix it.

Kid regards,

Matthias Schubert

issue for js comment

Hello i found an issue with Js for the comment :
If there is a comment like that :

// My comment
script....

he is not deleted

the regex that match the comment is : (?:/*(?:[\s\S]?)_/)|(?:^\s//(?:._)$)

but i dont know how to add it can you help me please Tx in advance !

Update readme

In lieu of a formal style guide, take care to maintain the existing coding style. Please apply fixes to both the development and production code. Don't forget to update the version number, and when applicable, the documentation.

Inline js comments

Hi, seems that the inline js comments within scripts added into the html are creating problems. The code underneath the comment is commented too. All of the content. There is no way to strip the js comments?

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.