# Overriding plugin javascript in a theme component

**URL:** <https://meta.discourse.org/t/overriding-plugin-javascript-in-a-theme-component/213748>\
**Category:** Development\
**Created:** [January 3, 2022, 8:42pm UTC](https://meta.discourse.org/t/overriding-plugin-javascript-in-a-theme-component/213748 "2022-01-03T20:42:28Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)\
**Post date:** [October 9, 2022, 8:34pm UTC](https://meta.discourse.org/t/overriding-plugin-javascript-in-a-theme-component/213748/10 "2022-10-09T20:34:37Z")

</div>

> [@david](#):
>
> Overriding entire files isn’t something we do ourselves, and it’s not something we recommend.

Is this true of templates too?

Scenario: I want to override a template deployed in a plugin. But I want to override in a code controlled way.

So I tried to ship the new template in a theme component. The same file exists in a plugin (but is different).

This appears to work on my dev cloud install but not in a standard production install.

So is it fair to say that you can’t predict if this will be successful or not with templates? ie the asset pipeline is such that you can’t predict which ‘template’ will stick as there is no predefined or predictable precedence?

I have been working with some strange assumption that there was a hierarchy, something like:

- core
- plugin
- theme component
- local site changes

And if you placed a “file” with the same path and name in a later level of that hierarchy, it would override any “previous” definition.

But my assumption is probably not safe?

Is the only “packaged” solution (ruling out local site changes) therefore to fork the plugin and make the changes directly within it?

That would in some senses be a shame as it would increase the maintainance effort for customisations as you’d have to merge in changes to the main plugin repo periodically …

---

_[View the full topic](https://meta.discourse.org/t/overriding-plugin-javascript-in-a-theme-component/213748)._
