# Disable javascript for disabled plugins

**URL:** https://meta.discourse.org/t/disable-javascript-for-disabled-plugins/68844
**Category:** Development
**Created:** [August 26, 2017, 8:11pm UTC](https://meta.discourse.org/t/disable-javascript-for-disabled-plugins/68844 "2017-08-26T20:11:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [August 26, 2017, 8:11pm UTC](https://meta.discourse.org/t/disable-javascript-for-disabled-plugins/68844/1 "2017-08-26T20:11:58Z")

</div>

One of the main issues people seem to have on Meta is broken plugins. There is a natural assumption that ‘disabling’ a plugin in the admin interface will stop any issues caused by it. The reality is that plugin javascript is still loaded, and can still completely break Discourse.

I have a working PR which ‘fixes’ this behaviour.

If you’ve ever looked at the `plugin_third_party.js` file, you’ll know it looks something like this (`eval` only used in development, but similar idea in production)

 ![59](https://global.discourse-cdn.com/meta/original/3X/e/8/e872581a420efe7ca4b09cbd99bd9098708e6ea5.png)

I’ve added a pre-processor which wraps those definitions so they end up like this:

 ![05](https://global.discourse-cdn.com/meta/original/3X/9/3/93a105cd42b4bcb861e591d605b1b6b301dee56a.png)

Then, before the application starts up, `discourse.js` steps through each one of those definitions, and will ignore any definitions for disabled plugins. (we already have a list of disabled plugins client-side for automatically disabling plugin outlets).

> <https://github.com/davidtaylorhq/discourse/blob/disable-plugin-js/app/assets/javascripts/discourse.js.es6#L105-L113>

As far as I can tell locally and on my instance, it works great. I can deliberately add a broken “import” line to a plugin file, see that the site is broken, go and disable the plugin, and then the site works again 🎉

Is this the right approach to be taking?

[https://github.com/discourse/discourse/pull/5103](https://github.com/discourse/discourse/pull/5103)

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [August 27, 2017, 1:47am UTC](https://meta.discourse.org/t/disable-javascript-for-disabled-plugins/68844/2 "2017-08-27T01:47:14Z")

</div>

If one disables a plugin is there a way to force it to load so that it can be enebled?

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [August 27, 2017, 10:13am UTC](https://meta.discourse.org/t/disable-javascript-for-disabled-plugins/68844/3 "2017-08-27T10:13:53Z")

</div>

The option to enable it is still available in the admin interface - that doesn’t need any JavaScript 🙂
