22

I am trying to ask a question on Stack Overflow but the code snippet button is missing for some reason.

Expecting this

Expected button available, which is the Snippet button in the editor's tool list

Currently Available

Current view, with the code snippet tool missing

How can I bring back the code snippet?

4
  • 1
    In the meantime, you should be able to copy the markup for a snippet into the post body in order to get one to show up, e.g.: <!-- begin snippet: js hide: false console: true babel: false --><!-- language: lang-js -->//<!-- end snippet -->
    – zcoop98
    Aug 16, 2022 at 19:27
  • 3
    There's also a semi-colon hiding up top. (it's here on meta too)
    – Kevin B
    Aug 16, 2022 at 20:02
  • 2
    The keyboard shortcut to create a snippet still works: Control-M Aug 16, 2022 at 20:13
  • 7
    We've identified the issue and have someone poking at it. :D
    – Catija
    Aug 16, 2022 at 20:44

1 Answer 1

19

Thanks for the report and patience! The fix for the missing Stack Snippets button (and semi-colon) has been deployed and is available throughout the network.

As we posted back in December 2021, we're moving our JS into Webpack bundles (albeit slower than anticipated) and the missing button for Stack Snippets was a result of migrating the JS for /questions/ask. Our old design of JS communicated largely via global variables and a lot of magic, so it can be hard to find and test everything that is dependent on each other as was seen with this bug.

If anyone is wondering why we didn't post an announcement for this change, well... As mentioned in the original post, there are hundreds of files that need to be migrated and we wouldn't want to spam everyone with hundreds of changes. So please pardon the dust and continue report bugs as per usual!

8
  • Do I gather, the code snippet will be available eventually (after all the behind the scene work is done)? If yes, when can I expect that to be available? If no, what should I expect instead of code snippet? Code snippet is super helpful for html-js.
    – smpa01
    Aug 16, 2022 at 22:30
  • 2
    @smpa01 I'm sorry, I missed the most important part in my answer. The code snippet button should be back again on SO (and other tech sites), could you confirm?
    – allejo
    Aug 16, 2022 at 22:39
  • 1
    Yes, it is available now. Thanks.
    – smpa01
    Aug 17, 2022 at 1:55
  • 2
    Re "a lot of magic": Nobody knows what it does or is supposed to do? Aug 17, 2022 at 2:02
  • 5
    @This_is_NOT_a_forum the biggest challenge is that a lot of our JS is old and fairly fragile; heck, we have JS files prefixed with numbers so that they are concatenated in the correct order otherwise things will break. In this case, the code for Stack Snippets injects itself into our editor instead of our editor code loading up that plugin. So when we're touching the editor e.g., we don't know off the top of our heads that something else in our hundreds of files will hook itself into it. This is what I mean by "magic."
    – allejo
    Aug 17, 2022 at 4:25
  • 2
    @allejo A more accurate term might be "chaos".
    – TylerH
    Aug 17, 2022 at 16:06
  • To compensate, we have two of those now. Sep 5, 2022 at 14:12
  • Having this problem again now on July 5th 2023 when creating a new question. I was able to add the snippet by editing the question after it was posted. Jul 5 at 23:19

You must log in to answer this question.

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