first go into the offical web js2mode
then goto the download page https://github.com/mooz/js2-mode
download and compile step:
$ git clone git://github.com/mooz/js2-mode.git
$ cd js2-mode
$ emacs --batch -f batch-byte-compile js2-mode.el
compilation is for the speed up the startup. then put the .elc file to your directory;at last config .emacs
(add-to-list 'load-path "/home/ryu/emacs/site/javascript")
(autoload 'js2-mode "js2-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(add-hook 'js2-mode-hook 'my-common-mode-auto-pair) #for auto-pair
js-mode is shiped with Emacs, so if you want to make specified setup for js-mode, you should use js-mode-hook.otherwise, as to js2-mode we should use js2-mode-hook.
now i use nxhtml-mode for my web programming, but now it just compatible with js-mode default mode in emacs. we still not able to use mix js2 and nxhtml in nxhtml-mode.
http://www.emacswiki.org/emacs/JavaScriptMode