Questions regarding require

Posted on
  • Hi Gordon,

    What happens, when i have modules on the sdcard and i upload the code via the WebIDE regarding "require" ?

    Will the module be loaded from the sdcard ?

    Thanks

    Sacha

  • Sorry, second question. When i use require in a condition like this:

    if(a=="extended")
    {
    require("modulename");
    }

    When i have the module on the sdcard will it be loaded at runtime if the condition is true. Memory on the board will be saved if the condition is false ?

    Thanks

    Sacha

  • No, the Web IDE doesn't know which modules are on the SD card so it'll load the latest module directly into Espruino anyway (and the module won't be loaded from the SD card).

    And yes, if you do that then the module will only be loaded if/when it is required. However because of above, the Web IDE will try and load it in. If you want to stop that happening, just make it a little harder for the Web IDE:

    var modulename = "modulename";
    require(modulename)
    
  • Hi Gordon,

    Many thanks for the answers. This helps a lot.

    Sacha

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Questions regarding require

Posted by Avatar for Sacha @Sacha

Actions