Module loading times

When the app initially loads on device, what is it that is loaded? I’m thinking about Lua modules and libraries of compiled code.

I’m asking because I’d like to know that if my main.lua is small but I have a very large module somewhere which I rarely load, does that large module get loaded into the (e.g.) phone’s memory during the time the Default.png is on screen? (the splash screen)

If not, does this mean that I could effectively make my app appear to load very quickly and later have a progress bar or some such animation while a further module is loaded?

I’ve seen native apps do this - or appear to do this - and I’ve seen native apps appear to have an animated loading instead of a Default.png, so is something similar possible with Corona?

As far as I know modules (lua files other than main and config lua) are loaded when you call require(“yourModule”).

So to answer your question, yes, that is possible. You can for example create a main.lua with a button in it and load the rest of your app when the user taps the button.

That’s the difference that I’m looking for - are the modules all compiled into a single binary which is loaded at application start or are they loaded at runtime only when the specified library is needed.

Update: ** See thought/note at end ** 

I’m 99% certain Modules are loaded-on-demand. 

You can verify this by creating an animation, then requiring a number of large modules or modules that do a lot of work as part of the first load.  You’ll see a hiccup in the animation.

Also, because you can unrequire them, this tells me they aren’t autoloaded for you.

Ex: this would be a module that did a lot of work during the require:

local public = {} public.values = {} -- pre-calculate and cache values -- -- Executes on first require. -- for i = 1, 1000000000, do public.values[i] = math.sqrt( i ) end function public.sqrt( i ) return public.values[i] end return public

Note: Even if the module is loaded-on-demand the question still exists:  “Is it loading from a pre-loaded pcode (or equivalent)?  i.e. A big bundle of pcode loaded into memory at launch?”  

Dang, now I’m wondering too.  Good question.

Lua experts!  Help!

As far as I know modules (lua files other than main and config lua) are loaded when you call require(“yourModule”).

So to answer your question, yes, that is possible. You can for example create a main.lua with a button in it and load the rest of your app when the user taps the button.

That’s the difference that I’m looking for - are the modules all compiled into a single binary which is loaded at application start or are they loaded at runtime only when the specified library is needed.

Update: ** See thought/note at end ** 

I’m 99% certain Modules are loaded-on-demand. 

You can verify this by creating an animation, then requiring a number of large modules or modules that do a lot of work as part of the first load.  You’ll see a hiccup in the animation.

Also, because you can unrequire them, this tells me they aren’t autoloaded for you.

Ex: this would be a module that did a lot of work during the require:

local public = {} public.values = {} -- pre-calculate and cache values -- -- Executes on first require. -- for i = 1, 1000000000, do public.values[i] = math.sqrt( i ) end function public.sqrt( i ) return public.values[i] end return public

Note: Even if the module is loaded-on-demand the question still exists:  “Is it loading from a pre-loaded pcode (or equivalent)?  i.e. A big bundle of pcode loaded into memory at launch?”  

Dang, now I’m wondering too.  Good question.

Lua experts!  Help!