-10

Suggestion to move the "Run Code Snippet" section of a JavaScript/HTML/CSS snippet before the code in Stack Overflow. The reason I think this will be preferable, is because if the result does not match the output you desire, it let's you review the code with more understanding of the output.

Or possibly have a preference option which the user can set for having this?

5
  • 3
    It's better to see the code first because it gives you a better understanding of the expected output IMO Commented Nov 28, 2019 at 20:42
  • How about letting the user decide how they would like to see it? Commented Nov 28, 2019 at 21:46
  • 5
    Who in their right mind wants to run code before reading it? Commented Nov 28, 2019 at 22:10
  • @JJf (should work), I realize the current context is about sandboxed Javascript code, but do you understand the security implications in the general case? But I digress, after all Stack Overflow does not want to start audio either. Commented Nov 28, 2019 at 22:28
  • 1
    @JJf, I wouldn't know, I only run Windows at work. My personal machines are running open-source software that is vetted by numerous people. I don't have the time to read all that source code, but they do, because they're working on it, and any attempt at committing nasty stuff will only result in the culprit having their reputation destroyed and being summarily disposed. Commented Nov 28, 2019 at 22:44

2 Answers 2

5

I don't think this would be a good feature.

It's not the worst idea but it's just not worth the effort for SE to implement.

the result does not match the output you desire, it let's you review the code with more understanding of the output

You can do this with the button below the code.

It would be a bad habit to run code before viewing it for security reasons. Today a safe sand boxed environment could have an exploit tomorrow or "harmlessly" crash your browser.

However, if you this is a feature you'd like to have personally, you may consider developing a browser add-on for it. If you do, consider keeping it open source in case others have an interest. Sounds like it could be a fun starter project in the world of browser add-ons.

1
  • I think that is a fair point. I will delete the question unless there is a way to close it? Commented Nov 29, 2019 at 0:17
0

I think this is a good idea because it puts the code next to the results. It is easier for my eyes to go back and forth without a row of buttons in between.

However, it could be confusing if there was a code sample right above the code snippet. You might think the "Run code snippet" button belongs to the other code.

For example:

console.log('hello world 01')

console.log('hello world 02')

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.