# How to add a custom toolbar button via external JS?

**URL:** <https://meta.discourse.org/t/how-to-add-a-custom-toolbar-button-via-external-js/69645>\
**Category:** Development\
**Created:** [2017年九月8日 16:22 UTC](https://meta.discourse.org/t/how-to-add-a-custom-toolbar-button-via-external-js/69645 "2017-09-08T16:22:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![godlike](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/godlike/32/77998_2.png) [@godlike](https://meta.discourse.org/u/godlike)\
**Post date:** [2017年九月8日 16:22 UTC](https://meta.discourse.org/t/how-to-add-a-custom-toolbar-button-via-external-js/69645/1 "2017-09-08T16:22:24Z")

</div>

Hi there,

I develop an image hosting script (Chevereto) and I’m building a universal JS plugin that aims to add external image hosting support for a wide range of forum CMS and websites in general. The idea is to achieve this without the need of a custom plugin for each CMS. So far I’ve added it successfully to IPB, Vanilla, XenForo, etc. The plugin is quite straightforward: It detects vendor, editor function and it picks a sibling to append my button element next to it.

For Discourse, I’m having issues since the editor template gets parsed on demand and I’m unable to find a good way to achieve this without the need to add some event handler or hack some object containing that section template.

I will like some guidance here in terms to try to get this to work without breaking something else. Please keep in mind that I’m aware of [this workaround](https://meta.discourse.org/t/adding-a-new-button-on-the-composer-toolbar/48725) but like I said earlier, I’m building it as an external plugin so I will look into that only if the external way is not reliable.

Hope there is way to do this,  
Thanks.
