hypixel skyblock
Dev icon This is a module documentation subpage for Module:Loader.
It contains usage information, categories and other content that is not part of the original module page.

Usage

The loader require and loadData are used to load a list of modules. These functions accept relative paths.

What is lazy load? When to use lazy load?

The term "lazy loading" is a strategy for loading resources.

Simply put, the lazy loading here is a layer between a required module and the code that accesses it. When running local string = loader.lazy.require('String'), the variable string is loaded with the layer, not the loaded module - in fact, the module is not loaded. The layer is responsible for loading the module when it is first accessed (string.trim()) or called (yesno()).

It will take up a little more memory and a tiny bit more access time. The benefit is that when a large amount of other modules are required for different parts of a module, only the used ones are required, while preserving the loading-on-top semantic and flexible package grouping that some programmers like. This untangles parts of the cobweb of modules that are required on a page, and reduces the impact to other modules during exceptions to one or a few modules.

If a module requires many other modules, but only a small subset will be used in most calls (when loading pages) to the module, it is beneficial to lazy load over normal load. If the other modules required are usually used every time it is called (when loading pages), then the benefit of lazy load is minimal to none compared to normal load.


Load Normally

The results work the same way as require() and mw.loadData().

local loader = require('Module:Loader')
local string, table, yesno = loader.require('String', 'Table', 'Yesno')
local myData, myData2 = loader.loadData('MyData', 'MyData2')

Lazy Load

The lazy loader returns a proxy (a special table) that loads the module when it is accessed the first time.
If used on table-like exports (packages or data tables) or function exports, the proxy can be used the same way as a table/function.
If used on other exports types, the loaded data will be loaded in the 'value' field in the resulting table.

local loader = require('Module:Loader')
local string, table, yesno = loader.lazy.require('String', 'Table', 'Yesno')
local myData, myData2 = loader.lazy.loadData('MyData', 'MyData2')

Submodules

No submodules found for this page. Try purging the page or viewing all subpages.


See Also

Hypixel SkyBlock Wiki Standard Lua Libraries (hsw/stdll) v · d · e
Type Libraries
Module Loading Utilities
General Utilities
Meta Modules
Object-oriented
Caching