Do not use the html editor that comes with Moodle. If you want to edit javascript code, is better to disable the html WYSIWYG html editor from your user profile.
Gabriel López
Text editors
Javascript in html editor
This discussion has been locked so you can no longer reply to it.