Board Thread:JS Development/@comment-9605025-20191030060753/@comment-33109274-20191206234128

(function {    'use strict';    var maxOutstandingRequests = 2;    var outstandingParses = $('.ParseWikitext').toArray;    var url = '/api.php?action=parse&pst&prop=text&format=json&text=';

function parse(elem) { if (!elem) return;

console.log('Sent Request'); jQuery.getJSON(url + encodeURIComponent(elem.innerHTML), function (reply) {           console.log('Received Reply');            if (reply && reply.parse && reply.parse.text && reply.parse.text['*'])                elem.innerHTML = reply.parse.text['*'];            parse(outstandingParses.shift);        }); }

for (var k=0; k<maxOutstandingRequests; k++) parse(outstandingParses.shift); });

With the for: (there are 2 async request on the go "at the same time") 2 Sent Request Received Reply Sent Request Received Reply Sent Request 2 Received Reply

Without the for (there's only 1): Sent Request Received Reply Sent Request Received Reply Sent Request Received Reply Sent Request Received Reply