# Import in HomeyScript

**URL:** <https://community.homey.app/t/import-in-homeyscript/47272>\
**Category:** Apps\
**Tags:** homeyscript\
**Created:** [May 11, 2021, 7:10am UTC](https://community.homey.app/t/import-in-homeyscript/47272 "2021-05-11T07:10:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![igorstefus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/igorstefus/32/34815_2.png) [@igorstefus](https://community.homey.app/u/igorstefus)\
**Post date:** [May 11, 2021, 7:10am UTC](https://community.homey.app/t/import-in-homeyscript/47272/1 "2021-05-11T07:10:24Z")

</div>

Is there way to import external functions in HomeyScript. I have some homey script functions that I want to be able to access in every other homey script so not sure how or if I can do that.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [May 11, 2021, 7:28am UTC](https://community.homey.app/t/import-in-homeyscript/47272/2 "2021-05-11T07:28:04Z")

</div>

> [@igorstefus](#):
>
> Is there way to import external functions in HomeyScript.

No, each Homeyscript runs in a “virtual machine context” that’s quite confined. So you need to copy&paste your code into each script.

---

<div class="post-metadata">

**Author:** ![igorstefus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/igorstefus/32/34815_2.png) [@igorstefus](https://community.homey.app/u/igorstefus)\
**Post date:** [May 11, 2021, 8:11am UTC](https://community.homey.app/t/import-in-homeyscript/47272/3 "2021-05-11T08:11:15Z")

</div>

Ok thanks!

---

<div class="post-metadata">

**Author:** ![Per\_Arne\_Slotte](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/per_arne_slotte/32/78879_2.png) [@Per\_Arne\_Slotte](https://community.homey.app/u/Per_Arne_Slotte)\
**Post date:** [October 2, 2023, 9:57am UTC](https://community.homey.app/t/import-in-homeyscript/47272/4 "2023-10-02T09:57:08Z")

</div>

I am somewhat surprised by the reply to this question. The answer answer itself, amounting to “you cannot write and import modules in HomeyScript” is correct, but the reasoning behind “why not” rings very wrong to me. There is nothing in the concept of an isolated “virtual machine context” that is violated by importing functions from a module. The reason it is not allowed in HomeyScript is simply that the people behind HomeyScript hasn’t opened for it. A request should be made because it would be very useful, as pointed out by @igorstefus

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [October 2, 2023, 10:07am UTC](https://community.homey.app/t/import-in-homeyscript/47272/5 "2023-10-02T10:07:23Z")

</div>

> [@Per\_Arne\_Slotte](#):
>
> but the reasoning behind “why not” rings very wrong to me

I’m not reasoning anything, I’m explaining how HomeyScript scripts are being run and how that doesn’t allow for external code to be imported. I’m not at all saying that such functionality wouldn’t be possible to implement.
