if (connection_latency.ival) return;

        connection_latency.ival = setInterval( function() {
            callback(now() - connection_latency.start);
        }, 1500 );

        return connection_latency.ival;
    }

    // This is how you use the code
    // Periodically Get Latency in Miliseconds
    connection_latency(function(latency){
        var out = PUBNUB.$('latency');
        out.innerHTML = "Latency: " + latency + "ms";

        // Flash Update
        PUBNUB.css( out, { background : latency 