I have a question, lets say i have a big function called bigFunction() that is being called inside Testing module in connect() function. If I packaged this function as a module and called it something like bigFunction and instead of calling this function from my Testing module I do a require("bigFunction").
When will the require do its job and grab the file? when i require the Testing module or when I call the function that requires it?
require("Testing") <--- Will it be loaded here?
require("Testing").connect() <--- includes require("bigFunction") or only here?
What I want is to only grab the big function if I required it to save space and memory
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I have a question, lets say i have a big function called bigFunction() that is being called inside Testing module in connect() function. If I packaged this function as a module and called it something like bigFunction and instead of calling this function from my Testing module I do a require("bigFunction").
When will the require do its job and grab the file? when i require the Testing module or when I call the function that requires it?
require("Testing") <--- Will it be loaded here?
require("Testing").connect() <--- includes require("bigFunction") or only here?
What I want is to only grab the big function if I required it to save space and memory