Search code examples
applescriptminifyyui-compressor

Is it possible to condense/minify AppleScript code?


I know you can minify/condense Javascript or CSS code, but can you do this with AppleScript?


Solution

  • Yeah, line feeds are the equivalent of the semicolon in C. You can use the "Chevron" syntax though.

    on run
        main()
    end run
    
    on main()
        tell application "Finder"
            display dialog "Hi."
        end tell
    end main
    

    converts to:

    on «event aevtoapp»
        main()
    end «event aevtoapp»
    
    on main()
        tell «class capp» "Finder"
            «event sysodlog» "Hi."
        end tell
    end main
    

    There is no enbiggening or rebigulation here, this is actually the raw syntax of the AppleScript. I used the Script Debugger app to switch between the two syntaxes.