I know how to load a Lua file via luaL_loadbuffer. Now I have many Lua files, more than 100. I am thinking about how to speed up the loading process. One way I figured out is: put all files into one, and then load this file using luaL_loadbuffer (I did some tests, but just got syntax error return by luaL_loadbuffer). Does anyone ever use this method? Or is there any other way to speed up the loading?
3
votes
2 Answers
0
votes
Expanding on @siffiejoe's comment and this answer to a related SO question, I use Squish to collapse multiple modules into a single .lua file. You can then use luac to compile it into bytecode, if desired.
luacshould speed loading. You can also combine many files into one precompiled file withluac, provided you don't userequireto load your files. - lhfpackage.preloadwould remove it... - Deduplicator