# Root script modules are not loaded

**URL:** <https://forum.inductiveautomation.com/t/root-script-modules-are-not-loaded/5301>\
**Category:** Ignition\
**Created:** [October 22, 2012, 9:02am UTC](https://forum.inductiveautomation.com/t/root-script-modules-are-not-loaded/5301 "2012-10-22T09:02:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![systemparadox](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@systemparadox](https://forum.inductiveautomation.com/u/systemparadox)\
**Post date:** [October 22, 2012, 9:02am UTC](https://forum.inductiveautomation.com/t/root-script-modules-are-not-loaded/5301/1 "2012-10-22T09:02:21Z")

</div>

When a script module is loaded from a package, the ScriptPackage calls ScriptModule.loadModule() to initialise it.

However, if a root script module (e.g. ‘foo’ instead of ‘app.foo’) is added using ScriptManager.addScriptModule(), that module’s loadModule method will never be called, as it isn’t being loaded from a package. This means that no functions or properties are set on the module object so it’s empty until loadModule() is called manually.

I can see two possible fixes for this:

1. Load root modules as soon as they are added. This is probably a bad idea. Error handling for this could be very difficult. Also, if this module depends on other modules it’s likely that they may not have been added yet.
2. Change ScriptModule. **findattr** to load the module first if it has not already been loaded.

Thanks.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 22, 2012, 8:39pm UTC](https://forum.inductiveautomation.com/t/root-script-modules-are-not-loaded/5301/2 "2012-10-22T20:39:29Z")

</div>

I’m gonna fix this using your second suggestion. I’m not sure this particular addScriptModule() call was ever meant to be exposed to 3rd parties, but let’s run with it and see what happens…

---

<div class="post-metadata">

**Author:** ![systemparadox](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@systemparadox](https://forum.inductiveautomation.com/u/systemparadox)\
**Post date:** [November 29, 2012, 3:32pm UTC](https://forum.inductiveautomation.com/t/root-script-modules-are-not-loaded/5301/3 "2012-11-29T15:32:09Z")

</div>

This appears to be fixed in 7.5.4.

Thanks.
