Scala.js 0.6.x: This environment is selected by default if your application or one of its libraries declares a dependency on the DOM, with jsDependencies += RuntimeDOM.
Note that this is deprecated, so you should use jsEnv := ... anyway.

PhantomJS

PhantomJS is a Webkit-based headless browser.
You can use it with Scala.js with the following sbt setting:

jsEnv:=PhantomJSEnv().value

Scala.js 1.x: The above setting requires the following line in your project/plugins.sbt:

addSbtPlugin("org.scala-js"%"sbt-scalajs-env-phantomjs"%"1.0.0-M1")

Disabling auto-termination of PhantomJS

By default, the PhantomJS interpreter terminates itself as soon as the main() method returns.
This may not be what you want, if for example you register time-outs or use WebSockets.
You can disable this behavior with the following setting:

jsEnv:=PhantomJSEnv(autoExit=false).value

You can terminate the interpreter from your Scala code with

System.exit(0)

Passing arguments to PhantomJS

You can pass command-line arguments to the PhantomJS interpreter like this: