# Run code first time a package precompile

**URL:** <https://discourse.julialang.org/t/run-code-first-time-a-package-precompile/73029>\
**Category:** New to Julia\
**Tags:** question, package\
**Created:** [December 13, 2021, 3:49pm UTC](https://discourse.julialang.org/t/run-code-first-time-a-package-precompile/73029 "2021-12-13T15:49:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [December 13, 2021, 3:49pm UTC](https://discourse.julialang.org/t/run-code-first-time-a-package-precompile/73029/1 "2021-12-13T15:49:36Z")

</div>

Hi,

Is it possible to run some code when a package precompile for the first time?  
I would like to run that code just once when precompilation happen.  
I don’t want to run it every time the package is loaded with `using mypackage`. I would like to avoid having to put my code in `function __init__ ()`

Thank you

---

<div class="post-metadata">

**Author:** ![zhubonan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zhubonan/32/31877_2.png) [@zhubonan](https://discourse.julialang.org/u/zhubonan)\
**Post date:** [December 13, 2021, 5:11pm UTC](https://discourse.julialang.org/t/run-code-first-time-a-package-precompile/73029/2 "2021-12-13T17:11:44Z")

</div>

Hmm, if you put the code in the module global scope, it will run at precompile time, and not when using it (which loads the precompiled state)
