Transferring code from a database to Javascript