CodeKit2 icon indicating copy to clipboard operation
CodeKit2 copied to clipboard

Request: UnCSS

Open bdkjones opened this issue 11 years ago • 42 comments

How about adding UnCSS ( https://github.com/giakki/uncss ) in the special language section to check and remove if there is unnecessary and unused css in your stylesheets in the post processing. Would be a nice addition to the already present Autoprefixer there. Best regards Ralf

bdkjones avatar Mar 14 '14 04:03 bdkjones

this would be AMAZING. It would allow us to work with big giant css libraries without worrying about the stuff we don't end up using.

BabylonSix avatar Mar 15 '14 13:03 BabylonSix

Oh that would be great!

Martinomagnifico avatar Mar 17 '14 20:03 Martinomagnifico

Upvote from me.

dcsturm avatar Mar 18 '14 08:03 dcsturm

Damn "Close & Comment" button...

dcsturm avatar Mar 18 '14 08:03 dcsturm

awesome tool

Grawl avatar Apr 07 '14 13:04 Grawl

:+1:

consciousimages avatar Apr 07 '14 22:04 consciousimages

Would this only work with .html / .kit?

yratof avatar Apr 08 '14 09:04 yratof

+1 for this idea

Andreyco avatar Apr 08 '14 17:04 Andreyco

Yup.

jbrooksuk avatar May 13 '14 09:05 jbrooksuk

+1 :)

thierrymichel avatar May 13 '14 13:05 thierrymichel

Yes please

rotx avatar May 26 '14 16:05 rotx

+1

tyssen avatar Oct 21 '14 21:10 tyssen

I just came here to request this.

Please!

Fequois avatar Oct 22 '14 10:10 Fequois

It would be awesome if you included uncss in the next release. I understand it wont be easy, but thats what you are known for :)

+1

avadhbsd avatar Nov 17 '14 08:11 avadhbsd

+1

bravocado avatar Nov 21 '14 07:11 bravocado

This is the one thing missing from Codekit for me. Love Codekit and would love to have something like uncss included.

trevorbarnes avatar Jan 25 '15 20:01 trevorbarnes

That would be amazing +1

1-800-jono avatar Feb 13 '15 14:02 1-800-jono

+1

dfosco avatar Feb 13 '15 17:02 dfosco

Please. Please don't make me go to gulp. Please.

joeguilmette avatar Mar 13 '15 16:03 joeguilmette

+1

fshequin avatar Mar 17 '15 17:03 fshequin

+1

mgkz avatar Mar 25 '15 07:03 mgkz

+1

chris-dvlpr avatar Apr 11 '15 12:04 chris-dvlpr

It's been over a year on this request, are there any updates on this you would like to share?

edwardsdesign avatar May 05 '15 18:05 edwardsdesign

Yea, it's something I'm still considering. I recall looking into the speed gains from "uncss-ing" stuff and finding that they were not statistically significant—doing this makes virtually no difference in page load times. As such, I questioned whether implementing it was a good idea.

bdkjones avatar May 05 '15 18:05 bdkjones

I did request this feature only last October, but I have since realised it really has no place in CodeKit (in my opinion). It's not a development tool, but part of a deployment process; it takes a considerable amount of time to run a pass on larger sites.

Not saying a "Let's Get Ready for Production" button wouldn't be cool, but... I just run my stylesheet through Gulp when I need to. Also, like you said, the benefit is negligible unless you use a large "framework" like Bootstrap or Foundation.

Just my five cents, or whatever the expression is. :)

Fequois avatar May 05 '15 19:05 Fequois

When we're using a large framework like Bootstrap or Foundation, it's always recomended to use it in a modular way. I mean, we can manually include or exclude the module by using @import (we're talking about CSS preprocessor, right?). And by doing that, we're automatically reduce our CSS file size. What if CodeKit have an unCSS ability? It would be nice but I think it's not necessary. And, I think my +1 on last November is just an impulsivity. :p

bravocado avatar May 05 '15 19:05 bravocado

We don’t need this feature, If we gzip on the server end, we don’t need to worry about much as long as we compress. And if your CSS does include loads of css that you’re not using, it might be worth looking at the source and manually figuring out why there’s unused CSS.

On 5 May 2015, at 20:23, bravocado [email protected] wrote:

When we're using a large framework like Bootstrap or Foundation, it's always recomended to use it in a modular way. I mean, we can manually include or exclude the module by using @import (we're talking about CSS preprocessor, right?). And by doing that, we're automatically reduce our CSS file size. What if CodeKit have an unCSS ability? It would be nice but I think it's not necessary. And, I think my +1 on last November is just an impulsivity. :p

— Reply to this email directly or view it on GitHub https://github.com/bdkjones/CodeKit/issues/306#issuecomment-99192936.

yratof avatar May 05 '15 19:05 yratof

Yea, this is roughly the same conclusion I've reached. I do think this thing has a place in a deployment workflow (which might be coming to CodeKit). But as a step in compiling an individual file, I'm less convinced.

When using massive frameworks like Bootstrap or Foundation, I think the right approach is to @import only the modules you need. Foundation makes that super easy. I believe Bootstrap does as well.

bdkjones avatar May 05 '15 20:05 bdkjones

I think this discussion is pretty great. After reading through, I'd agree that:

  1. UnCSS doesn't belong in Dev
  2. CodeKit is in desperate need of a deployment process

On Wed, May 6, 2015 at 3:01 AM Bryan Jones [email protected] wrote:

Yea, this is roughly the same conclusion I've reached. I do think this thing has a place in a deployment workflow (which might be coming to CodeKit). But as a step in compiling an individual file, I'm less convinced.

When using massive frameworks like Bootstrap or Foundation, I think the right approach is to @import only the modules you need. Foundation makes that super easy. I believe Bootstrap does as well.

— Reply to this email directly or view it on GitHub https://github.com/bdkjones/CodeKit/issues/306#issuecomment-99203712.

joeguilmette avatar May 06 '15 04:05 joeguilmette

While the comments about deployment vs development are certainly correct, I still think that this feature would be useful. The reason is that there is no such thing as a bug free tool (that's not a knock on uncss, just a fact). So in order to avoid surprises and weird effects, I would like to have the development output as close to possible to the deployment output, and uncss would be part of both. Thanks for your consideration.

rotx avatar May 06 '15 13:05 rotx

Very valid points all around, I agree that UnCSS should be apart of the deployment and it would be great if CodeKit had this as a workflow option. To be honest, I was hoping that this would of been a jumpstart to allow for 3rd party extensions to run as part of the CodeKit process, like sass extensions without the need for the ruby config file.

edwardsdesign avatar May 06 '15 14:05 edwardsdesign

Codekit has hooks though – Can you not hook a gulp process?

On 6 May 2015, at 15:36, Chris Edwards [email protected] wrote:

Very valid points all around, I agree that UnCSS should be apart of the deployment and it would be great if CodeKit had this as a workflow option. To be honest, I was hoping that this would of been a jumpstart to allow for 3rd party extensions to run as part of the CodeKit process, like sass extensions without the need for the ruby config file.

— Reply to this email directly or view it on GitHub https://github.com/bdkjones/CodeKit/issues/306#issuecomment-99493706.

yratof avatar May 06 '15 14:05 yratof

After consideration, I don't think that this is desirable in CodeKit. Actually, I'm not sure it's desirable in the way that I built apps at all.

devilskitchen avatar May 09 '15 23:05 devilskitchen

I downloaded the trial yesterday to assess for refactoring some Wordpress/Woocommerce CSS ~5000 lines across ~10 files ( a commercial theme plus... ). PSI mobile is hurting re UnusedCSS above the fold. Ditto minify / concatenate CSS ( yup theres a plugin for that https://wordpress.org/plugins/bwp-minify/ )

I was expecting more CSS pre/post processing to be honest. CodeKit and the UI is great when you don't want to learn / setup NPM, Gulp etc ( nor have the time ) but lacks CSS processing IMHO.

So yes to UnCSS please, but CSSLint, CSSMinify first for plain old CSS files. Envisioning

/sass /css /dist ( the optimised theme style.css )

... unless I am missing some CodeKit functionality ?

philval avatar Jul 28 '15 12:07 philval

@philval

You're describing a very difficult task. Bryan would either need implement a Node environment within CodeKit or instruct users to set it up themselves and hook it into CodeKit. Then CodeKit would need to parse dozens to hundreds of pages, neither of which are static HTML files on disk. If you run it on a limited sample you'll lose styles you need.

I'm a bit out of my depth here talking about the process involved, but from my limited understanding of how it works, it sounds terribly complicated and resource intense. Ultimately we, the developers, need to write flexible and maintainable code. We can't run everything through a mill.

What would be super-cool is PostCSS support. Like GUI configuration for some common tasks, and perhaps even support for custom tasks if you write the snippets. Would still require magic, but an interesting thought.

Fequois avatar Jul 28 '15 12:07 Fequois

+1

JayHoltslander avatar Jan 21 '16 19:01 JayHoltslander

I must admit this would be a very handy inclusion. I'm currently using it with Gulp but it would be nice to have it all handled in one place.

johnniefp avatar Feb 10 '16 18:02 johnniefp

I was toying around today with uncss (npm install -g uncss) and managed to get it to work with Codekit's hooks. Although not the perfect solution, as we need to pass the url by hand. I tried to create a bash script to loop through the results but got no luck. I'll try via AppleScript later, using http://www.mousedown.net/mouseware/JSON_Examples.html

The hook to app.scss is:

sleep 5
uncss http:/localhost/about/ > ~/Sites/scss/uncss.scss

I'm exporting to .scss as uncss unminify the css. To Codekit will generate uncss.css after that.

sjardim avatar Feb 29 '16 23:02 sjardim

It seems that UnCSS is using PostCSS now: https://github.com/giakki/uncss/blob/master/package.json#L44

calvinjuarez avatar Apr 21 '16 21:04 calvinjuarez

Would be a great feature, especially if you work with framework (foundation, bootstrap) scss.

eheiser avatar Oct 14 '16 13:10 eheiser

@bdkjones What are the chance you could do a YouTube video walkthrough of achieving this utilizing Codekit's hooks? I've seen the docs on hooks but would find a video with Grunt or Gulp examples very helpful. I'm hoping to use this with a Wordpress theme as others have recommended.

JayHoltslander avatar Sep 28 '17 21:09 JayHoltslander

You would not use Grunt or gulp. Just install uncss with npm, then take a look at its CLI instructions. Your hook calls the CLI just like if you were running uncss from the terminal. Except that you’ll want to use those special variables CodeKit makes available to Hooks for the input and output file paths.

Sent from my iPhone

On Sep 28, 2017, at 14:39, Jay Holtslander [email protected] wrote:

@bdkjones What are the chance you could do a YouTube video walkthrough of achieving this utilizing Codekit's hooks? I've seen the docs on hooks but would find a video with Grunt or Gulp examples very helpful. I'm hoping to use this with a Wordpress theme as others have recommended.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

bdkjones avatar Sep 28 '17 22:09 bdkjones