# Injecting JS at footer.html

**URL:** <https://talk.getindico.io/t/injecting-js-at-footer-html/1397>\
**Category:** Administrators\
**Created:** [August 8, 2019, 11:53am UTC](https://talk.getindico.io/t/injecting-js-at-footer-html/1397 "2019-08-08T11:53:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![selkie](https://talk.getindico.io/user_avatar/talk.getindico.io/selkie/32/139_2.png) [@selkie](https://talk.getindico.io/u/selkie)\
**Post date:** [August 8, 2019, 11:53am UTC](https://talk.getindico.io/t/injecting-js-at-footer-html/1397/1 "2019-08-08T11:53:08Z")

</div>

Hi,

I am implementing a mobile-friendly navigation menu and would like to place some JS at the end of each page.

Previously I got it to work by replacing the whole footer.html template and including it into tags at the end.

After updating to 2.2, I had a look again at [footer.html](https://github.com/indico/indico/blob/87a73e4e161caa77230d520cd7dc5d250502d136/indico/web/templates/footer.html) and noticed that it does mention some kind of injected\_js at line 45

```auto
{{- g.get('injected_js', []) | join('\n') | safe -}}

```

but I cannot figure out how to use this to inject my own JS.

Any pointers?

Thanks,  
Ying

---

<div class="post-metadata">

**Author:** ![ThiefMaster](https://talk.getindico.io/user_avatar/talk.getindico.io/thiefmaster/32/509_2.png) [@ThiefMaster](https://talk.getindico.io/u/ThiefMaster)\
**Post date:** [August 8, 2019, 12:03pm UTC](https://talk.getindico.io/t/injecting-js-at-footer-html/1397/2 "2019-08-08T12:03:05Z")

</div>

The `inject_js` thing isn’t really new; maybe it was just used from somewhere else before. Anyway, It’s not meant to be used from plugins.

To properly inject custom JS on specific pages, use a plugin and call `self.inject_bundle()`. If you only need it for customizations and want to include it on all pages, you could also use the js folder inside the `CUSTOMIZATION_DIR` and put it there.

---

<div class="post-metadata">

**Author:** ![selkie](https://talk.getindico.io/user_avatar/talk.getindico.io/selkie/32/139_2.png) [@selkie](https://talk.getindico.io/u/selkie)\
**Post date:** [August 8, 2019, 2:36pm UTC](https://talk.getindico.io/t/injecting-js-at-footer-html/1397/3 "2019-08-08T14:36:06Z")

</div>

> [@ThiefMaster](#):
>
> To properly inject custom JS on specific pages, use a plugin and call `self.inject_bundle()` . If you only need it for customizations and want to include it on all pages, you could also use the js folder inside the `CUSTOMIZATION_DIR` and put it there.

Thanks, some of the JS I needed (addEventListener) needed to be placed at the end of the page, while the js folder places it into the header. I haven’t figured out how to write a plugin, so I will just continue with replacing the footer.html for now.

---

<div class="post-metadata">

**Author:** ![ThiefMaster](https://talk.getindico.io/user_avatar/talk.getindico.io/thiefmaster/32/509_2.png) [@ThiefMaster](https://talk.getindico.io/u/ThiefMaster)\
**Post date:** [August 8, 2019, 2:38pm UTC](https://talk.getindico.io/t/injecting-js-at-footer-html/1397/4 "2019-08-08T14:38:02Z")

</div>

Doesn’t need to be at the bottom if you wrap it like this:

```auto
document.addEventListener('DOMContentLoaded', () => {
  // put your code here
});

```
