Javascript: Working on code emission