# My plugin codes runs just once!(My own script shouldn't be cached)

**URL:** https://meta.discourse.org/t/my-plugin-codes-runs-just-once-my-own-script-shouldnt-be-cached/51301
**Category:** Development
**Created:** [Octobre 9, 2016, 2:08 UTC](https://meta.discourse.org/t/my-plugin-codes-runs-just-once-my-own-script-shouldnt-be-cached/51301 "2016-10-09T14:08:49Z")
**Posts on this page:** 1
**Showing post:** 18

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [Novembre 21, 2016, 10:10 UTC](https://meta.discourse.org/t/my-plugin-codes-runs-just-once-my-own-script-shouldnt-be-cached/51301/18 "2016-11-21T22:10:29Z")

</div>

@broz

If you can figure out how to make your javascript a function and not execute it immediately, then you can simply put that function statement at the bottom of your initializer and call it from within the onPageChange invocation.

Similar to what the poll plugin is doing here

> [@Existing JS module import into ES6 plugin](https://meta.discourse.org/t/existing-js-module-import-into-es6-plugin/52713/2):
>
> This is an example of plugin that modifies post cooking: [https://github.com/discourse/discourse/blob/master/plugins/poll/assets/javascripts/lib/discourse-markdown/poll.js.es6](https://github.com/discourse/discourse/blob/master/plugins/poll/assets/javascripts/lib/discourse-markdown/poll.js.es6)

---

_[View the full topic](https://meta.discourse.org/t/my-plugin-codes-runs-just-once-my-own-script-shouldnt-be-cached/51301)._
