Hacker News new | past | comments | ask | show | jobs | submit login
A Better Way to Manage CSS and JS (+ source code) (gathercontent.com)
14 points by legierski on June 19, 2012 | hide | past | favorite | 17 comments



While I don't mind the concept proposed, a few things immediately caught my eye:

1) How often are changes made to these CSS files? It seems to me that caching would be far more crucial than any marginal benefit of this practice. Also, what of allowing multiple CSS files to download in parallel via multiple <link> tags?

[nitpicking from here out]

2) Why does his minify code remove all whitespace and then remove whitespace before '{' and after ':'? They're already gone.

3) Removing all whitespace makes the assumption that no whitespace is necessary. This will completely break, among other things, font-family: "Some Embedded Font";


1) CSS on dev setup changes very often. Limiting number of <link>'s was one of the goals.

2) It does not. The ' ' is actually a double space.

3) Point 2)


Ahh double space, that makes much more sense. Sorry for not looking more closely before posting.


I've done this before and its far from the best way.

Pre-compilation is better and is CDN safe out-of-the-box.


So on the fly you open tons of text files to glue them? Seems i/o intensive.

Why not do the same thing on deploy?


Or, do the best of both worlds.

Get your web server involved and it becomes brainless:

http://www.gethifi.com/blog/Automatic-file-minification-on-n...


We’ll introduce server-side caching in the future, but a goal of this script was to provide users with the latest CSS/JS at all times...


Surely, it would be acceptable to microcache for a few seconds? It's rather easy, with nginx in front.


+1 Not to mention that a stylesheet named "_dynamic.php?v=blehbleh&lx=12&vs=4.3.3" isn't really welcome.


Rails 3 asset management / precompiling FTW


Better than what? This doesn't mention any of the other asset management tools out there.


Better than using only one file with all css inside


out of topic but couldn't help noticing shorthand php tags <?= ?> these make me cringe


Why? If your server is running PHP and you're not worried about confusion with some other language processor, then why not use shorthand?


It's no longer a valid SGML processing instruction, which largely rules out decades of tools for working with markup.


I'm curious as to what tools you're using to work with files containing PHP code. I mean that sincerely -- if you've got something you really like, it'd be great to learn something new!


Can you give me an example? I was honestly surprised that the shorthand PHP syntax would ever be an issue.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: