# Kibana plugin dev: loading order for "hacks"

**URL:** <https://discuss.elastic.co/t/kibana-plugin-dev-loading-order-for-hacks/178763>\
**Category:** Kibana\
**Created:** [April 27, 2019, 6:32pm UTC](https://discuss.elastic.co/t/kibana-plugin-dev-loading-order-for-hacks/178763 "2019-04-27T18:32:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simone\_Scarduzio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simone_scarduzio/32/17128_2.png) [@Simone\_Scarduzio](https://discuss.elastic.co/u/Simone_Scarduzio)\
**Post date:** [April 27, 2019, 6:32pm UTC](https://discuss.elastic.co/t/kibana-plugin-dev-loading-order-for-hacks/178763/1 "2019-04-27T18:32:51Z")

</div>

In my plugin index.js I declare 5 "hacks" as an array.

They are all loaded, but the order Kibana runs them is not the same I am declaring them. In fact the ordering happens to be: 1,5,3,2,4 instead of 1,2,3,4,5.

This is a problem because some hacks rely on dom objects that are being injected by another hack.

I think the declared order for hacks should be respected by Kibana.

---

<div class="post-metadata">

**Author:** ![timroes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timroes/32/19712_2.png) [@timroes](https://discuss.elastic.co/u/timroes)\
**Post date:** [April 29, 2019, 2:33pm UTC](https://discuss.elastic.co/t/kibana-plugin-dev-loading-order-for-hacks/178763/2 "2019-04-29T14:33:15Z")

</div>

Hi Simone,

there is currently no guarantee on the execution order of hacks. If you need them to be executed in a very specific order, I would recommend creating one file, that you put into your `hacks` array and just `import` the other files in this file, in which case the order will stay deterministic.

Since we are currently working on a new platform ([https://github.com/elastic/kibana/issues/9675](https://github.com/elastic/kibana/issues/9675)) which will change a lot of extension points and way of things to function, I think there won't be any further changes to the way we load `hacks` and instead rely in the future on new platform capabilities for that.

Cheers,  
Tim

---

<div class="post-metadata">

**Author:** ![Simone\_Scarduzio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simone_scarduzio/32/17128_2.png) [@Simone\_Scarduzio](https://discuss.elastic.co/u/Simone_Scarduzio)\
**Post date:** [May 6, 2019, 7:37pm UTC](https://discuss.elastic.co/t/kibana-plugin-dev-loading-order-for-hacks/178763/3 "2019-05-06T19:37:49Z")

</div>

Hi Tim, thanks for the answer.  
Do you mean that when the old platform's plugin API will be dropped, we won't have the possibility to define "hacks" at all?

Also, where can I find an example of a plugin that targets the new platform only? Or even some documentation about the current new platform's plugin API?

---

<div class="post-metadata">

**Author:** ![timroes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timroes/32/19712_2.png) [@timroes](https://discuss.elastic.co/u/timroes)\
**Post date:** [May 7, 2019, 9:12am UTC](https://discuss.elastic.co/t/kibana-plugin-dev-loading-order-for-hacks/178763/4 "2019-05-07T09:12:44Z")

</div>

Hi,

I think there will also be in the new platform a way to provide "generic loaded JS" functionallity via plugins (maybe @Court can clarify on that?) The new platform is currently still a work in progress so there are no complete plugins yet using only new platform and nothing else. You can find the documentation that exists already here: [https://github.com/elastic/kibana/tree/master/src/core](https://github.com/elastic/kibana/tree/master/src/core)

Cheers,  
Tim

---

<div class="post-metadata">

**Author:** ![Court](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/court/32/6640_2.png) [@Court](https://discuss.elastic.co/u/Court)\
**Post date:** [May 7, 2019, 2:27pm UTC](https://discuss.elastic.co/t/kibana-plugin-dev-loading-order-for-hacks/178763/5 "2019-05-07T14:27:02Z")

</div>

> I think there will also be in the new platform a way to provide "generic loaded JS" functionallity via plugins

This is correct. The new plugin system by its very nature loads JavaScript from every plugin, so while there won't be the notion of "hacks" in the sense that there is today, many hack extensions will be able to be moved into the plugin class itself as part of the new platform migration.

It's worth emphasizing at this point that we'll provide a lot more information about the new plugin system in 7.x to help people migrate. We won't turn off the old plugin system while plugin developers are still in the dark.

---

<div class="post-metadata">

**Author:** ![Simone\_Scarduzio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simone_scarduzio/32/17128_2.png) [@Simone\_Scarduzio](https://discuss.elastic.co/u/Simone_Scarduzio)\
**Post date:** [May 8, 2019, 6:28pm UTC](https://discuss.elastic.co/t/kibana-plugin-dev-loading-order-for-hacks/178763/6 "2019-05-08T18:28:12Z")

</div>

Thank you @Court and @timroes. I suppose the new info and documentation will be published somewhere here?

> **[elastic/template-kibana-plugin](https://github.com/elastic/template-kibana-plugin)**
>
> sao.js template for kibana plugins. Contribute to elastic/template-kibana-plugin development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 5, 2019, 6:28pm UTC](https://discuss.elastic.co/t/kibana-plugin-dev-loading-order-for-hacks/178763/7 "2019-06-05T18:28:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
