Coder Social home page Coder Social logo

HTML Minification ? about express-minify HOT 18 OPEN

breezewish avatar breezewish commented on May 20, 2024 2
HTML Minification ?

from express-minify.

Comments (18)

iatek avatar iatek commented on May 20, 2024 3
  • 1 for html

from express-minify.

faeb187 avatar faeb187 commented on May 20, 2024 2

ah ok, thought issues are only bugs here, thx mate.
--> just did some tests.. you're right, the best practice seems to be minifying + gzip

Then it would be nice to have support for all of them:

  • Jade
  • EJS
  • plain HTML

from express-minify.

marceloboeira avatar marceloboeira commented on May 20, 2024 1

All feature requests are issues, not only problems, or bugs.
Just to be clear, html minification, with EJS or any other engine:

Code before:

<ul>
    <li>A</li>
    <li>B</li>
    <li>C</li>
    <li>D</li>
</ul>

Code after:

<ul><li>A</li><li>B</li><li>C</li><li>D</li></ul>

With any other render optimizations, of course.

from express-minify.

breezewish avatar breezewish commented on May 20, 2024 1

Minifying template is a good idea because it can be safely cached :-)

from express-minify.

marceloboeira avatar marceloboeira commented on May 20, 2024 1

@joeytwiddle it could be several params, because there cases you may want to minify css inside <style> tags, or even javascript code on atributes...

cases like:

<a property="value"></a>

to

<a property=value></a>

or

<i class="icon-x"></i>

to

<i class="icon-x" />

....

from express-minify.

marceloboeira avatar marceloboeira commented on May 20, 2024 1

I really want to minify, because I make a lot of requests with pjax, and all the HTML comes with spacing...

from express-minify.

breezewish avatar breezewish commented on May 20, 2024 1

@marceloboeira Have you enabled gzip? According to those real world test results, gzip is really an effective way to reduce traffic.

from express-minify.

marceloboeira avatar marceloboeira commented on May 20, 2024 1

@breeswish yeap. but I guess html minification could help me even more.

from express-minify.

h2non avatar h2non commented on May 20, 2024 1

+1

from express-minify.

PeterDaveHello avatar PeterDaveHello commented on May 20, 2024 1

+1 for html output minify

from express-minify.

faeb187 avatar faeb187 commented on May 20, 2024

Support for jade would be nice!! I think that's what you want ;)
For 'normal HTML' GZIP is supported in express-minify

BTW this is a feature request and not an issue.. please move

from express-minify.

marceloboeira avatar marceloboeira commented on May 20, 2024

@faeb187 weird. heh

from express-minify.

joeytwiddle avatar joeytwiddle commented on May 20, 2024

I just want to warn, that occasionally HTML minification can change the meaning of a page! Specifically I experienced it when the browser was interpreting newlines as a gap, and the minifier removed those newlines (and indentation).

Given certain CSS settings (I forget which property now),

<span>
    Thing
</span>

is equivalent to:

<span> Thing </span>

But if you minify it to

<span>Thing</span>

then the resulting output is different! (You have lost the gap.)

For that reason, we stopped using Jade's built-in minifier for production, and stuck with un-minified HTML, like we had in development mode.

This is a rare issue, but it might trip people up (although if they use the minifier in both dev and prod mode, then they should be ok).

from express-minify.

joeytwiddle avatar joeytwiddle commented on May 20, 2024

One other concern, if you are minifying but not caching, then you might be making the network transfer faster, but slowing down the actual response! This depends on the size of your HTML, and the speed of your minifier (related to CPU power of course). If you are caching semi-static pages, then this only applies to the first request, so no problem. And if it is optional, then the dev can make the decision for themself. Just wanted to warn about that too. ;)

from express-minify.

mcandre avatar mcandre commented on May 20, 2024

Bleugh, tired of waiting. Found https://www.npmjs.com/package/express-minify-html

It's not perfect, would love for regular express-minify to gain this ability...

from express-minify.

marceloboeira avatar marceloboeira commented on May 20, 2024

this is oooooooooooooold as hell. I haven't done JS since 2015. hahah a

from express-minify.

mcandre avatar mcandre commented on May 20, 2024

express-minify-html's last commit was in 2017 and now features a high severity vulnerability.

Let's just add basic HTML minification to regular express-minify.

from express-minify.

Martii avatar Martii commented on May 20, 2024

Re: @mcandre

... and now features a high severity vulnerability.

Where would that be? e.g. no really.... citation is needed please.

Refs:

$ npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
added 6 packages from 41 contributors and audited 7 packages in 0.524s
found 0 vulnerabilities

$ npm audit
                                                                                
                       === npm audit security report ===                        
                                                                                
found 0 vulnerabilities
 in 7 scanned packages

from express-minify.

Related Issues (20)

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.