Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div class="main">
  <div class="header">
    <h1>Speed Test with Javascript</h1>
  <div class="content">
    <button id="starttest">Start</button>
  <div id="results">
  <div id="disclaimer">
    <p>We regret due the early publish of this alpha version, we're still not comatible with all browsers. Tested with Chrome (27) and Firefox (21). This is not a final version.</p>


  font-size: 12px;
  font-family: 'Offside'; 
  background-color: #E6F6D8;
  font-size: 4.5em;
  text-align: center;
  font-size: 3.5em;
  text-align: center;
  margin: 20px;
  text-align: center;
  height: 120px;
  background-color: #71D971;
  border: 0px;
  border-radius: 15px;
  width: 400px;
  height: 100px;
  color: white;
  font-size: 3em;
  font-family: 'Offside'
  background-color: #40B440;
  -webkit-box-shadow:  5px 5px 10px 1px rgba(0, 0, 0, .5);
  box-shadow:  5px 5px 10px 1px rgba(0, 0, 0, .5);
  font-size: .8em;
  color: gray;
  text-align: center;


  Para poder poner este script en tu server tienes que poner tambien un archivo en tu server y saber de que tamaño es para poner la informacion en imageAddr y downloadSize.

var imageAddr = "" + "?n=" + Math.random();
var startTime, endTime;
var downloadSize = 5616998; //5.36Mb
var download = new Image();
var roundedDecimals = 2;
var bytesInAKilobyte = 1024;

function showResults() {
  var duration = (endTime - startTime) / 1000;
  var bitsLoaded = downloadSize * 8;
  var speedBps = ( bitsLoaded / duration ).toFixed(roundedDecimals);
  var displaySpeed = speed(speedBps);
  var results = "<h2>Your connection speed is<h2><h1>" + displaySpeed.value + " " + displaySpeed.units + "</h1>"
      $('#results').fadeIn('fast', function(){
        $('#starttest').text('Thank You!');

function speed( bitsPerSecond ){
  var KBps = (bitsPerSecond / bytesInAKilobyte).toFixed(roundedDecimals);
  if ( KBps <= 1 ) return { value: bitsPerSecond, units: "Bps" };
  var MBps = (KBps / bytesInAKilobyte).toFixed(roundedDecimals);
  if ( MBps <= 1 ) return { value: KBps, units: "KBps" };
  else return { value: MBps, units: "MBps" };

$('#starttest').on('click', function(){
  $('#starttest').text('Wait, downloading...');
  $('#starttest').attr('disabled', 'disabled');
  download.onload = function () {
    endTime = (new Date()).getTime();
  startTime = (new Date()).getTime();
  download.src = imageAddr;