2

I just wrote this answer and in the last paragraph I decided to create a small utility as part of the answer. The utility is needed for the process. After submitting, I found that Android Enthusiasts doesn't have Stack Snippets enabled, so I ended up leaving the JS utility in the Sandbox and providing a link.

The question is, in such scenarios where I want to provide a coded utility (JavaScript or something else), especially on non-programming-oriented sites, what is a good way to do so?


Some side notes: I didn't think of GitHub (GitHub Gists) this time because

  1. GitHub Gists don't code to be executed directly, whereas Stack Snippets do
  2. "Link-only answers can become invalid if the linked page changes." and I believe that Stack Exchange links are in general more reliable than GitHub links.
  3. While GitHub Pages may be an alternative, there are just too many downsides and instability
2

Here's my suggestion: include a link to a place (e.g. JS Fiddle, CodePen) where the code can be run, and also include the code in the post in a code block. If the code is long, it makes sense to minify it so it all fits on one line, thus reducing the space it takes up on the page.


The formatting sandbox should not be used like this because the answer is going to be eventually moved and the link breaks. In addition, the last time I tried to view the sandbox archive my browser (Chrome) almost crashed (in any case, the page didn't load), so fixing the link when it breaks isn't a great solution either.

  • hmm, moving answers to the SB Archive does not break existing /a/<id> links so it's gonna be reliable to the extent of Stack Exchange's uptime. – iBug Sep 21 '18 at 15:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .