It's not convenient to write code through the wiki except for very small fixes. Do the following instead.
Say you want to work on MediaWiki:Gadget-monthnav.js. The most direct is to edit, code, save and test. But submitting every time is time consuming. As you re-open the page, you have to look for the piece of code you were working on, etc. So substitute the content for:
mw.loader.load('http://localhost/dev/monthnav-dev.js?' + Date.now(), 'text/javascript');
The ?' + Date.now() appends a timestamp so the browser never serves a stale cached copy.
Then in /var/www/html/dev dump the file itself, which you can edit, say, with Emacs. When happy with the result, revert the content to the wiki page and synchronize.