As far as I know, you can't establish a socket connection from Javascript. That means that the XMPP connection needs to be piggy-backed on top of either HTTP or Websocket. BOSH (described in XEP-0124 and XEP-0206) is a way to run XMPP on top of HTTP.
I believe Google Talk and Facebook Chat do not provide BOSH or Websocket endpoints, so you'd either need to run a proxy yourself or use their native APIs.