Your implementation saves the output of js-beautify to a tmp file. Can you not simply replace the input region with the shell command's output?
(shell-command-on-region START END COMMAND &optional OUTPUT-BUFFER REPLACE
ERROR-BUFFER DISPLAY-ERROR-BUFFER)
...
Optional fourth arg OUTPUT-BUFFER specifies where to put the
command's output. If the value is a buffer or buffer name, put
the output there. Any other value, including nil, means to
insert the output in the current buffer. In either case, the
output is inserted after point (leaving mark after it).
Optional fifth arg REPLACE, if non-nil, means to insert the
output in place of text from START to END, putting point and mark
around it.
Your implementation saves the output of js-beautify to a tmp file. Can you not simply replace the input region with the shell command's output?