I'm not sure of how much use this would be on other SEs, but on CodeGolf.SE, we use Stack Snippets more often to actually provide useful functionality, than to demo some code of interest.

In that case, no one wants to look at that huge wall of code, all you want is the snippet. So what I tend to do is run the code through external minifiers, so all the line breaks go. Since I've got to use separate HTML, CSS and JS minifiers, that's quite annoying.

It would be nice if there was a "Minify" button next to the "Tidy" button. It doesn't even have to shorten variable names and stuff, just get rid of unnecessary whitespace - basically the exact inverse to "Tidy".

(Yes, I am aware that snippets can be hidden by default, but once you expand it, you still have to scroll past a wall of code to get to the actual snippet.)

Edit: Being able to hide/expand the code and the button/snippet individually, would also solve the problem.

  • 1
    The sentence you edited in at the end sounds like the ideal solution. – trichoplax Jan 25 '15 at 14:11
  • @trichoplax Yes, it's probably the easiest change. Of course, being able to minify the code would also have the advantage of taking up less characters towards the 30k post limit. – Martin Ender Jan 25 '15 at 14:16
  • Alternative solution: Don't count Stack Snippets towards the 30k post limit, and collapse them by default if they are larger than X number of lines. Currently, they only collapse if the snippet contains a specific comment in the code. – Rainbolt Jan 26 '15 at 16:34
  • @Rainbolt As I said, I don't think collapsing the entire snippet is helpful, if I can only see the snippet button if I also expand all the code. You still have to scroll down a few pages to get to the button. And collapsing them by default is probably not desirable on SO, say, where snippets are probably most often used to demo working code (so if that was collapsed by default, the main content of the answer might be collapsed). – Martin Ender Jan 26 '15 at 16:38
  • @MartinBüttner Who said anything about collapsing the button? I only suggested collapsing the supposedly large snippet of code behind it. Leave the button alone. I also said by default. If a huge chunk of code is, for whatever reason, the main attraction of your answer, then <!-- begin snippet: js hide: false -->. – Rainbolt Jan 26 '15 at 16:53

You must log in to answer this question.

Browse other questions tagged .