# api.modifyClass sometimes(!) not working

**URL:** https://meta.discourse.org/t/api-modifyclass-sometimes-not-working/212413
**Category:** Bug
**Created:** [December 17, 2021, 7:54am UTC](https://meta.discourse.org/t/api-modifyclass-sometimes-not-working/212413 "2021-12-17T07:54:25Z")
**Posts on this page:** 1
**Showing post:** 18

<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: [April 18, 2023, 10:39am UTC](https://meta.discourse.org/t/api-modifyclass-sometimes-not-working/212413/18 "2023-04-18T10:39:17Z")

</div>

I’ve just improved our warning for this kind of situation:

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

and also written up this documentation which explains the cause and how to resolve it:

> [@Using modifyClass to change core behavior](https://meta.discourse.org/t/using-modifyclass-for-objects-which-are-initialized-early-in-boot/262064):
>
> For advanced themes and plugins, Discourse offers the modifyClass system. This allows you to extend and override functionality in many of core’s javascript classes. When to use modifyClass modifyClass should be a last resort, when your customization cannot be made via Discourse’s more stable customization APIs (e.g. plugin-api methods, plugin outlets, transformers). Core’s code can change at any time. And therefore, customizations made via modifyClass could break at any time. When using this A…

I think that should take care of all the concerns in this topic. If not, please share some example failing code and I’ll take a look.

---

_[View the full topic](https://meta.discourse.org/t/api-modifyclass-sometimes-not-working/212413)._
