TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: A Genetic approach to CSS compression

63 pointsby friggeriover 12 years ago

6 comments

franzeover 12 years ago
<p><pre><code> however, although the resulting file size is smaller, once gzipped it actually leads to larger files than by only using minification, therefore this is a totally useless article, </code></pre> no, it's not. mobile devices have a relatively small cache size, and assets are cached in non-gzip-ed form. so non-gezip-ed filesize is important (on mobile, that is)
评论 #4570729 未加载
评论 #4570903 未加载
merrakshover 12 years ago
The problem might be NP-hard, but with modern commercial (CPLEX, Gurobi, Xpress) and open-source (Cbc, SCIP) solvers for discrete optimization you can find a provably optimal solution in a relatively short time, even for thousands of nodes.<p>The disadvantage of genetic algorithms is that they are heuristics, with no guarantees on the quality of the solution found. Exact solvers such as the ones above do provide an estimate of how far you are from the optimal solution if you decide to stop them before they terminate.
muxxaover 12 years ago
What about if you rerun the genetic algorithm with the fitness function being the size of the final compressed+gzipped file? Maybe that could counter-intuitively reorder the CSS so that there are more long runs of repetitive rules which result in an optimum final level of compression.
评论 #4570974 未加载
friggeriover 12 years ago
OP here, available to answer your questions if you have any.
评论 #4570776 未加载
SageRavenover 12 years ago
Best practice for serving .css files is gzippped? Is this at the file level or on-the-fly by the web server? In any case, why is this considered best practice? (I ask as a sysadmin, not a web developer.)
评论 #4571246 未加载
评论 #4571103 未加载
halbermenschover 12 years ago
Quite interesting though, as far as "useless" ideas go.