Board Thread:Lua Help/@comment-4405550-20160107031030

Would it be too much trouble to add a compressor/minifier for modules? It doesn't have to be powerful.

Hell, I really just want it to connect the string I break apart onto multiple lines.

For example, I might make the following:

local myVar = ' ' ..		' ' ..			SpanStuff .. ' ' ..		' ' ..			' ' ..				innerSpanStuff .. ' ' ..		' ' ..	' '

It's fairly simple, no need for the html builder, and keeping it like this makes it far easier to read. But all of those concats are pointless till edits need to be made.

So in the mean time, a minifier could make the module more efficient by reducing it to the following with no side effects.

local myVar = ' ' .. SpanStuff .. ' ' .. innerSpanStuff .. '  '

I know what you are going to say, and I KNOW it's more efficient to put it all in a table and concat that way. This is just an example. There are a ton of different reasons why you might want just a simple string.

But simple improvements can be made to almost any module. for example:

if type(myVar) == "boolean" then -- do Stuff end The following is equivalent, but far faster for Lua to process: if myVar == true or myVar == false then -- do Stuff end

And going back to the string example, a smart enough minifier can convert that into a table.concat statement (but if done wrong, it could break some code).

Minifiers/compressors do currently exist for Lua, but aren't very good and aren't fully compatible with the MediaWiki's version of Lua.

Hell, with a few regular expressions and this could all be done in JS an posted as a site enhancement/userscript.

The original un-compressed code could be stored as a subpage like "Module:MyModule/code" before being minified to the man module page.

Any thoughts or ideas? 