Live data from Hacker News

What CSS minifiers also leave behind

luisant.ca

51–60 of 109 posts

Re: What CSS minifiers also leave behind

#51

Earlier quoted context omitted.

One massive thing minifying does is dead code elimination (slightly less applicable to CSS but it still applies using some build stacks) We can build a "prod" version of the app and the minifying process will drop all the debugging code as well as any unused or uncalled functions from the output.

What JS Minifier do you know that does dead code elimination? I would have thought that understanding what functions of a dynamic language that can be safely removed would require parsing/AST analysis beyond those found in the typical minifier.

I use uglifyjs and it does a pretty good job of it.

We use blocks like this throughout our codebase:

    if (process.env.NODE_ENV === 'development') {
      fancyDebuggingFunction(stuff)
    }
    // ... some code later
    fancyDebuggingFunction(var) {
      /* do debugging things here */
    }
And when combined with some stuff that sets the process.env.NODE_ENV (not sure how that part works honestly, never really looked into it) it will remove not only the if statement, but also the function if it's not called anywhere and not exported.

Throw in Webpack 2's import/export bundling stuff, you can exclude whole modules which you don't use in production which can really reduce the size of your code.

And moving forward if the JS ecosystem can ever get a handle on a good way to move to import/export by default, you'll start seeing massive gains in this area by being able to strip out any parts of a library that you don't use.

Also, I believe most widely used minifiers use AST parsing to do their work.

Re: What CSS minifiers also leave behind

#52
post #44

Earlier quoted context omitted.

"q" is also CSS3, incidentally, and its background is interesting[0]: it's a mostly japanese metric typographical unit[1], it replaces the point, and is slightly smaller: q is 0.25mm while pt is ~0.3528mm (precisely 1/72th of an inch which is 25.4mm). [0] http://tosche.net/2013/10/font-size-in-the-metric-system_e.h... [1] although non-japanese typographers like Otl Aicher have recommended its use it doesn't seem to h…

"q" seems to be doomed to failure. If I were that interested in moving away from points and ems, why would I adopt arbitrary fractions of a millimeter when I could just use plain old SI units that are universally understood? It doesn't even save a byte at typical font sizes: 20q == 5mm.

Saving bytes in CSS was probably not the primary concern upon standardization in 1976. Note that the PostScript point (now the most common definition) is younger than that. Common usage doesn't always follow the best option that's available, as evident by many examples throughout history.

Furthermore, having a measurement that can frequently be used with integer dimensions is convenient, which is probably a large part why we still use points. 12 pt is a convenient font size, so is 4 mm (technically 4.2 mm, as 11.8 pt would be 4 mm), but while 10 pt is still convenient, 3.5 mm is less so. Smaller units lead to more useful integer values (within reason, of course).

Re: What CSS minifiers also leave behind

#53

Earlier quoted context omitted.

One massive thing minifying does is dead code elimination (slightly less applicable to CSS but it still applies using some build stacks) We can build a "prod" version of the app and the minifying process will drop all the debugging code as well as any unused or uncalled functions from the output.

What JS Minifier do you know that does dead code elimination? I would have thought that understanding what functions of a dynamic language that can be safely removed would require parsing/AST analysis beyond those found in the typical minifier.

The dojo build system (as clunky as it is) has supported dead code elimination at the module level though dependency analysis for a long time.

Re: What CSS minifiers also leave behind

#54

Are there any good tools for deobfuscating css/js if you want to study a technique used on some web page?

Not sure it's a great solution for deep study, but if you just need a quick peek, the Chrome developer tools include a pretty print/ format option when applicable: https://developers.google.com/web/tools/chrome-devtools/java...

Re: What CSS minifiers also leave behind

#55
post #2

I'm for hire now. Le Sigh. Email's in the footer. Remy: I'd suggest posting a CV and linking to it from this post. I looked and couldn't find one anywhere on your site; you'll get a lot more qualified interest if people can find out more about you than just a few blog posts.

I thought about it, but I'm way too shy for that. Not like it would lead to anywhere either, you know. :P Two years of teaching university, MSc in computing, love of automation, combinatiorial optimization without any significant amount of deep math skill, circuit design, gate array stuff, low-level CPU optimization stuff, hardware counters, microcontrollers, SQLite, Julia language, C, shell, a bunch more programming…

Some unsolicited advice:

1. I am not interested in jobs that focus on JavaScript, but I'd never say "No JavaScript".

2. when people ask for your CV, post a link (or if you're concerned about privacy, solicit requests via PM/email).

3. Your integrity, sillyness and attire are mostly immaterial to the job hunt. It's most appropriate for folks to make this kind of assessment during an in-person interview.

4. what is all this "nothing will come of it" business? If you think you can't get hired as a result of an HN post, I think you're sorely mistaken. Capitalize on these fifteen minutes. You've created some original, interesting content. The traffic you're getting to your site won't last, so strike while the iron is hot.

Re: What CSS minifiers also leave behind

#56
If folks tend to use some higher level abstraction (isn't that what SASS and LESS are?) maybe it makes sense to provide a new way to encode the information in CSS. Similar to how WASM is supposed to be easier to parse than JavaScript, right?

Re: What CSS minifiers also leave behind

#57
post #44

Earlier quoted context omitted.

"q" is also CSS3, incidentally, and its background is interesting[0]: it's a mostly japanese metric typographical unit[1], it replaces the point, and is slightly smaller: q is 0.25mm while pt is ~0.3528mm (precisely 1/72th of an inch which is 25.4mm). [0] http://tosche.net/2013/10/font-size-in-the-metric-system_e.h... [1] although non-japanese typographers like Otl Aicher have recommended its use it doesn't seem to h…

"q" seems to be doomed to failure. If I were that interested in moving away from points and ems, why would I adopt arbitrary fractions of a millimeter when I could just use plain old SI units that are universally understood? It doesn't even save a byte at typical font sizes: 20q == 5mm.

It's in CSS because of its use in Japan; not an attempt to get elsewhere to adopt it.

Re: What CSS minifiers also leave behind

#58

Earlier quoted context omitted.

I thought about it, but I'm way too shy for that. Not like it would lead to anywhere either, you know. :P Two years of teaching university, MSc in computing, love of automation, combinatiorial optimization without any significant amount of deep math skill, circuit design, gate array stuff, low-level CPU optimization stuff, hardware counters, microcontrollers, SQLite, Julia language, C, shell, a bunch more programming…

Man, just post a link to CV like you're advised and let good things happen to you. If they don't, you lose nothing, but if they do, you got something out of your effort.

Seriously, somebody saw he's looking for a job, and was actually looking for his CV as somebody in charge of hiring might do

Re: What CSS minifiers also leave behind

#59

Here's the same author's earlier post on this subject, "The missed chances: What minifiers leave behind", from last week: https://luisant.ca/css-opts-survey

Anybody know if the transparency one is actually a desirable optimization? Iirc, you might want to assign a color to your transparency so it's not shifting hue as you fade it in through CSS transitions, animations, or JS.

Re: What CSS minifiers also leave behind

#60
post #26
post #2

I'm for hire now. Le Sigh. Email's in the footer. Remy: I'd suggest posting a CV and linking to it from this post. I looked and couldn't find one anywhere on your site; you'll get a lot more qualified interest if people can find out more about you than just a few blog posts.

Pro tip: you can increase your chances of getting hired by 4.2% by not saying Le Sigh .

Dunno about OP, but I wouldn't want to work for anyone who doesn't appreciate Le Sigh.
Post reply on HN