/minify

Primary LanguageJavaScript

Automatically minify all client Lua files when the server starts

Setup

Download the latest release and place in your resources folder, rename to minify
In your server.cfg, add ensure minify at the start of your resource list, it is key that this resource starts before any other script you want to use it on.
This will not run this on every resource by default, to enable it, add

minify "yes"

to the fxmanifest.lua

This will go through every file in the client/ folder, minify the contents of the file, and copy in a new folder called client_min, it is important you change this in the fxmanifest.lua, so the minified files are loaded.
I would recommend adding client_min/ to your .gitignore

This will not protect your code

It will only make it harder to read for the average player

-- before
RegisterNUICallback("spawnVehicle", function(data)
    if IsPedInAnyVehicle(PlayerPedId(), false) then
        TriggerEvent("ui:notification", "error", "You are already in a vehicle")
        return
    end
    PlaySound(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 0, 0, 1)
    TriggerServerEvent("arena:spawnVehicle", data.spawncode)
end)

-- after
RegisterNUICallback("spawnVehicle",function(a)if IsPedInAnyVehicle(PlayerPedId(),false)then TriggerEvent("ui:notification","error","You are already in a vehicle")return end;PlaySound(-1,"SELECT","HUD_FRONTEND_DEFAULT_SOUNDSET",0,0,1)TriggerServerEvent("arena:spawnVehicle",a.spawncode)end)