Is it possible to use JavaScript to dynamically add a custom button to the ribbon?
I want to add a button next to the upload document button in a document library.
Any ideas or code how to do that?
Based on the hashtag 2013 I guess your question is for Sharepoint 2013?
Back in time I created a JS library to do what you're looking for: https://github.com/Aymkdn/RibbonPlus
You can add button to the ribbon using Custom Actions.
Check below references for more information & code: