Which socket transports are available in the JavaScript SDK?

By default, the JavaScript SDK will automatically select the best transport method during run-time. However, you can override this for only two specific transports (Flash Socket Streaming or JSONP) by specifying the transport during initialization manually to enforce JSON(P) or Flash Socket transport.

This is not recommended unless you know what you are doing because PubNub will automatically pick the best transport for you.

For Flash Socket transport ( must use div tag):

    <div id="pubnub" flash=true></div>
    <script>
        var flash_socket = PUBNUB.init({
            publish_key : 'pub-c-...',
            subscribe_key : 'sub-c-...'
        });
    </script>

For JSON(P) transport ( must not use div tag):

    <script>
        var pubnub = PUBNUB.init({
            jsonp : true,
            publish_key : 'pub-c-...',
            subscribe_key : 'sub-c-...'
        });
    </script>