Scribunto-console

Here's a crazy trick: you can evaluate an arbitrary chunk of Lua code, without creating any modules, using the  API. Here's what the local documentation has to say about it:

* action=scribunto-console * Internal module for servicing XHR requests from the Scribunto console This module requires read rights Parameters: title              - The module title to test content            - The new content of the module session            - question           - The next line to evaluate as a script This parameter is required clear              - Set this to true to clear the current session state

You can also check Wikipedia's documentation for a few extra details.

Usage
This API serves as a nice bridge between Scribunto and JavaScript, and can be used thusly:

Or for a more concrete example:

The server should respond with a blob of JSON, like one of these:

Caveats
There are three major drawbacks to this technique (hack?):


 * 1) You have to make a HTTP request.
 * 2) It has a limit of 500,000 characters (bytes?).
 * 3) The result is always coerced to a string.

In other words, don't use it unless you need Scribunto functionality, and try to accomplish what you want with as little Lua as possible. Global modules are your friend.