PageSourceSearch

https://packetlosstest.com/assets/script.terser.js

js packetlosstest.com collected 2026-10-02 05:50:01 UTC 20,767 bytes, 2 lines download raw bytes

1"use strict";const isSimple=!!document.getElementById("simpleResults"),startDisabledReasons=new Set,maxPings=7e4,maxData=31457280,minimumInterval=15;let totalData,savedSettingsHeight,updatePredictedUse=()=>{};if(!isSimple){const e={7:{"🠥":"⬆","🠧":"⬇"}};navigator.userAgent.includes("Windows NT 10")||Object.entries(e[7]).forEach((e=>document.body.innerHTML=document.body.innerHTML.replace(new RegExp(e[0],"g"),e[1])));const t=document.getElementById("preset");t&&(t.onchange=()=>{let e=t.options[t.selectedIndex];["size","frequency","duration","wait"].forEach((t=>{if(t in e.dataset){let n=document.getElementById(t+"Slider");n.value=e.dataset[t],n.dispatchEvent(new Event("input"))}}))});const n=new URLSearchParams(window.location.search),s=parseInt(n.get("size"))-115;if(s){let e=document.getElementById("sizeSlider");e.max<s&&s<=10117&&(e.max=s),e.value=s,e.oninput()}const i=parseInt(n.get("duration"));if(i){let e=document.getElementById("durationSlider");e.max<i&&(e.max=i),e.value=i,e.oninput()}const a=parseInt(n.get("frequency"));if(a){let e=document.getElementById("frequencySlider");e.max<a&&(e.max=a),e.value=a,e.oninput()}const o=parseInt(n.get("acceptableDelay")||n.get("delay"));if(o){let e=document.getElementById("waitSlider");e.max<o&&(e.max=o),e.value=o,e.oninput()}const r=n.get("preset");r&&([...t.children].forEach((e=>{e.innerText===r&&(e.selected=!0)})),t.dispatchEvent(new Event("change")));const l=document.getElementById("server"),c=n.get("serverName");c&&[...l.children].forEach((e=>{e.innerText===c&&(e.selected=!0)}));const d=n.get("serverUrl");d&&(l.value=d),document.addEventListener("click",(function(e){document.querySelectorAll("nav details[open]").forEach((t=>{t.contains(e.target)||(t.open=!1)}))}))}["durationSlider","frequencySlider","totalPings","sizeSlider","totalData","pingsThatAreTooMany","totalPingsReason","dataThatIsTooMuch","totalData"].every((e=>document.getElementById(e)))&&(updatePredictedUse=function(){let e=parseInt(document.getElementById("durationSlider").value),t=1e3/parseInt(document.getElementById("frequencySlider").value);t>15&&(t=Math.round(t));const n=Math.floor(1e3*e/t);document.getElementById("totalPings").innerHTML=n;const s=document.getElementById("totalPingsPluralizer");s&&(s.style.display=n>1?"inline":"none");const i=document.getElementById("totalPingsSingleWord");i&&(i.style.display=n>1?"inline":"none"),totalData=n*parseInt(document.getElementById("sizeSlider").value)+115,document.getElementById("totalData").innerHTML=totalData<1024?`~${totalData} bytes`:totalData<1048576?`${(totalData/1024).toFixed(1)} KB`:`${(totalData/1024/1024).toFixed(2)} MB`;let a=n>7e4,o=totalData>maxData;if(a||totalData>maxData){let e;e="en"===document.documentElement?47:100,a?(document.getElementById("pingsThatAreTooMany").innerHTML=document.getElementById("totalPingsReason").innerText,tooManyPingsMessage.style.display="inline",e+=18):(tooManyPingsMessage.style.display="none",document.getElementById("pingsThatAreTooMany").innerHTML=""),o?document.getElementById("dataThatIsTooMuch").innerHTML=document.getElementById("totalData").innerText:(tooManyPingsMessage.style.display="none",document.getElementById("dataThatIsTooMuch").innerHTML=""),window.innerWidth>=500?(savedSettingsHeight||(savedSettingsHeight=settings.clientHeight),settings.style.height=savedSettingsHeight+e+"px"):settings.style.height="",Array.from(document.getElementsByClassName("usageThatIsTooMuchAnd")).forEach((e=>e.style.display=a&&o?"inline":"none")),usageStopMessage.style.display="block",start.disabled=!0,startDisabledReasons.add("use")}else savedSettingsHeight&&(settings.style.height="",savedSettingsHeight=!1),usageStopMessage.style.display="none",tooManyPingsMessage.style.display="none",startDisabledReasons.delete("use"),startDisabledReasons.size||(start.disabled=!1)}),updatePredictedUse(),document.querySelectorAll("summary").forEach((e=>e.addEventListener("mousedown",(function(e){e.detail>1&&e.preventDefault()}),!1)));let latePings,firstRun=!0;start.onclick=()=>{(!totalData||totalData<3145728||window.confirm(`This test as you've configured it will use ${(totalData/1024/1024).toFixed(2)} MB of bandwidth for both of us. Are you sure you want to run it?`))&&runTest()};const results=document.getElementById("simpleResults")||document.getElementById("results"),progress=document.getElementById("simpleProgress")||document.getElementById("progress"),workerUrl="https://packetlosstest.com/assets/worker.js";let worker;function runTest(){const e=isSimple?15:parseInt(document.getElementById("frequencySlider").value),t=isSimple?10:parseInt(document.getElementById("durationSlider").value),n=isSimple?105:parseInt(document.getElementById("sizeSlider").value),s=isSimple?200:parseInt(document.getElementById("waitSlider").value),i=isSimple?0:document.getElementById("delayedStart").checked?parseInt(document.getElementById("delayedStart").value):0;firstRun&&!isSimple&&(about.open=!1,settings.open=!1,firstRun=!1),start.disabled=!0,startDisabledReasons.add("running"),results.style.display="none",errorSection.style.display="none";const a=document.getElementById("server");let o=a?a.value:"wss://lse.packetlosstest.com/ws";const r=a?a.options[a.selectedIndex].text:"Georgia";let l,c,d=new WebSocket(o);d.onerror=failTest,latePings=[];let h,u,g,m=[],p=0,y=0,f=!1;d.onopen=a=>{gtag("event","websocket",{event_label:"opened"}),d.send("sending waiting text"),l=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"turn:hde.packetlosstest.com:3478",username:"packetlosstest",credential:"packetlosstest"},{urls:"turn:vnlt.packetlosstest.com:3478",username:"packetlosstest",credential:"packetlosstest"}]}),d.pinger=setInterval((()=>{try{d.send("")}catch(e){}}),5e3),c=0,h=[];
1let o=l.createDataChannel("channel",{ordered:!1,maxRetransmits:0});o.onopen=a=>{let r;progress.open=!0,progress.style.display="block";const l=1e3/e;function b(){o.send(JSON.stringify({i:c++,time:(new Date).getTime()}).padEnd(n," ")),f?isSimple||document.querySelector("sent-circle-thingy").current++:y++}function w(){if(f=!0,void 0!==r&&setTimeout((()=>{clearInterval(r)}),1e3*t),!isSimple){progress.querySelectorAll("sent-circle-thingy, time-circle-thingy, received-circle-thingy").forEach((e=>{e.wait=s,"SENT-CIRCLE-THINGY"!==e.tagName&&"RECEIVED-CIRCLE-THINGY"!==e.tagName||e.start(Math.floor(1e3*t/l)),"TIME-CIRCLE-THINGY"===e.tagName&&e.start(t)}));const e=setInterval((()=>{document.querySelector("time-circle-thingy").current++}),1e3);setTimeout((()=>{clearInterval(e),document.querySelector("time-circle-thingy").current=t}),1e3*t)}setTimeout((()=>{if(o.close(),d.send(JSON.stringify({type:"done"})),isSimple||document.querySelector("received-circle-thingy").finish(),results.style.display="block",results.open=!0,h.length){h.sort(((e,t)=>e.i-t.i)),u=h.reduce(((e,t)=>({ping:e.ping+t.ping}))).ping/h.length;let e=0,t=0;for(let n=0;n<h.length;n++)e+=Math.abs(h[n].ping-u),h[n].i!==n+t&&(m.push(n),p++,t++);g=e/(h.length-1),isSimple||(latency.innerHTML=u.toFixed(2),jitter.innerHTML=g.toFixed(2))}else isSimple||(latency.innerHTML="∞",jitter.innerHTML="∞");let e=h.length+p;if(e<c-y)for(p+=c-e;e<c;e++)m.push(e);if(isSimple)setSimpleResults(p,c-y);else{setResults(packetLoss,p,c-y),0===p&&(setResults(upload,p,c-y),setResults(download,p,c-y)),setResults(document.getElementById("late"),latePings.length,c-y);let e=new Array(c).fill(null);h.forEach((t=>e[t.i]=t.ping)),drawChart(e,s,u,g),disableDownloads()}endStartButtonRunningDisable()}),1e3*t+s+l+500)}l>15?r=setInterval(b,Math.round(l)):(worker.onmessage=e=>{!0===e.data.send&&b()},worker.postMessage({interval:l,duration:1e3*(i+t)})),i?setTimeout(w,1e3*i):w()},o.onmessage=e=>{if(f){let t=JSON.parse(e.data);if(t.i>=y){let e=(new Date).getTime()-t.time;t.i-=y;let n={i:t.i,ping:(new Date).getTime()-t.time};h.push(n),e<=s&&!isSimple?document.querySelector("received-circle-thingy").received(t.i):(latePings.push(n),isSimple||document.querySelector("received-circle-thingy").received(t.i,!0))}}},l.onconnectionstatechange=e=>l.connectionState,l.oniceconnectionstatechange=e=>l.iceConnectionState,l.onicecandidate=e=>{e.candidate&&d.send(JSON.stringify({type:"ice",ice:e.candidate}))},l.onicecandidateerror=failTest,l.createOffer().then((e=>l.setLocalDescription(e))).then((()=>{d.send(JSON.stringify(l.localDescription))}))},d.onmessage=i=>{if(!i.data)return!1;var a;try{a=JSON.parse(i.data)}catch(e){}if(a)if("answer"===a.type)l.setRemoteDescription(a).catch((e=>{console.log(e)}));else if("results"===a.type){a.list.sort(((e,t)=>e-t)),a.list.splice(0,y),a.receivedCount-=y;for(let e=0;e<a.list.length;e++)a.list[e]-=y;let i=[];for(let e=0;e<a.receivedCount;e++)if(0===e&&0!==a.list[e])i.push(0);else if(a.list[e]!==a.list[e-1]+1)for(let t=a.list[e-1]+1;t<a.list[e];t++)i.push(t);isSimple||(document.querySelector("sent-circle-thingy").setResults(i),prepareDownloads(c,h,i,p,latePings.length,c-y,u,g,t,e,n+115,s,r),setResults(upload,i.length,c-y),setResults(download,p-i.length,a.receivedCount))}else"ice"===a.type&&l.addIceCandidate(a.ice).catch((e=>{console.log(e)}));return!1},d.onclose=e=>{clearInterval(d.pinger),console.log("WebSocket closed")}}function failTest(e){if(701!=e.errorCode){endStartButtonRunningDisable(),"block"!==errorSection.style.display&&(progress.open=!1,results.open=!1,errorContent.innerHTML=`<p>Sorry, some error has stopped the test from starting. This could be my bad, or your connection could have just failed. Feel free to try again.</p>\n\t\t<pre>Error ${e.target instanceof WebSocket?"with WebSocket":e.errorCode||e.code}: ${e.target instanceof WebSocket?`Unable to connect to ${e.target.url}`:e.errorText||""}</pre>
1${e.target instanceof WebSocket&&navigator.userAgent.startsWith("Mozilla/5.0 (Macintosh")?'<p>If you are using a Mac computer, there has been some update in 2021 that has broken the site in Safari and Chrome. I do not own a Mac, and I am unsure how this is possible, but I am working on identifying and fixing the problem. Any clues are appreciated. In the mean time, I recommend using Firefox, as it has been reported to not suffer from the change:</p><a href="https://www.mozilla.org/en-US/firefox/" title="Mozilla Firefox"><img src="https://cdnjs.cloudflare.com/ajax/libs/browser-logos/48.0.4/firefox/firefox_48x48.png" alt="Firefox Logo" /></a>':""}`,console.log(e),errorSection.style.display="block");try{e.target instanceof WebSocket&&gtag("event","websocket",{event_label:"failed"}),gtag("event","exception",{description:e.target instanceof WebSocket?`Unable to connect to ${e.target.url}`:e.errorText||"Unknown error",fatal:!0})}catch(e){}}}function endStartButtonRunningDisable(){startDisabledReasons.delete("running"),startDisabledReasons.size||(start.disabled=!1)}"packetlosstest.com"===document.domain?worker=new Worker(workerUrl):fetch(workerUrl).then((e=>e.blob())).then((e=>worker=new Worker(URL.createObjectURL(e)))),isSimple&&runTest();const badColor="#E53A43",goodColor="#E2690C",grayColor="#CCCCCC",lateColor="#E2980C",maybeColor="#F5A262";class ProgressCircleThingy extends HTMLElement{static defaultColor(){return goodColor}get current(){return this.getAttribute("current")}set current(e){e?this.setAttribute("current",e):this.setAttribute("current","0"),this.update()}get total(){return this.getAttribute("total")}set total(e){e?this.setAttribute("total",e):this.setAttribute("total","0")}get percent(){return this.getAttribute("percent")}set percent(e){this.setAttribute("percent",e),this.percentText.innerHTML=(100*e).toFixed(0)+"%"}constructor(){super(),this.style.position="relative";let e,t,n=this.attachShadow({mode:"open"});function s(e=200){let t=document.createElement("canvas");t.style.position="absolute";let s=window.matchMedia("(min-width: 665px)");function i(e){e.matches?t.style.marginLeft="15px":t.style.marginLeft="0"}i(s),s.addListener(i),t.width=e,t.height=e,t.style.maxWidth="calc((100vw - 20px) / 3)",t.style.maxHeight="calc((100vw - 20px) / 3)",n.appendChild(t);let a=t.getContext("2d");return a.lineWidth=15,[t,a]}[e,t]=s(),t.strokeStyle="#CCCCCC",t.arc(e.width/2,e.width/2,e.width/2-15,.6*Math.PI,.4*Math.PI),t.stroke(),[e,t]=s(),t.strokeStyle=goodColor,this.canvas=e,this.context=t;let i=document.createElement("div");this.bigText=i;let a=window.matchMedia("(min-width: 450px)");function o(e){e.matches?i.style.fontSize="42px":i.style.fontSize="9.75vw"}o(a),a.addListener(o),i.style.padding="35% 0 0",i.style.margin="0 auto",i.style.textAlign="center",i.style.width="50%",n.appendChild(i);let r=document.createElement("div");this.smallText=r,r.style.fontSize="16px",r.style.margin="5px auto",r.style.paddingLeft="50%",r.style.width="50%",n.appendChild(r);let l=document.createElement("div");this.percentText=l,l.style.fontFamily="'Squada One', sans-serif",l.style.fontSize="20px",l.style.margin="calc(10px + 8%) auto 7%",l.style.textAlign="right",l.style.width="15%",n.appendChild(l)}start(e){this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.strokeStyle=this.constructor.defaultColor(),this.painted=0,this.total=e,this.current=0}update(){this.bigText.innerHTML=this.getAttribute("current"),this.smallText.innerHTML="/ "+this.getAttribute("total"),this.percent=this.getAttribute("current")/this.getAttribute("total")}}class SentCircleThingy extends ProgressCircleThingy{static defaultColor(){return"#F5A262"}update(){super.update(),this.context.beginPath(),this.context.arc(this.canvas.width/2,this.canvas.width/2,this.canvas.width/2-15,.6*Math.PI+1.8*Math.PI*(this.painted/this.getAttribute("total")),.4*Math.PI-1.8*Math.PI*(1-this.percent)),this.context.stroke(),this.painted=this.getAttribute("current")}setResults(e){this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.strokeStyle=goodColor,this.context.beginPath(),this.context.arc(this.canvas.width/2,this.canvas.width/2,this.canvas.width/2-15,.6*Math.PI,.4*Math.PI-1.8*Math.PI*(1-this.percent)),this.context.stroke(),this.context.strokeStyle=badColor;let t=this.getAttribute("total");e.forEach((e=>{this.context.beginPath(),this.context.arc(this.canvas.width/2,this.canvas.width/2,this.canvas.width/2-15,.6*Math.PI+1.8*Math.PI*(e/t),.4*Math.PI-1.8*Math.PI*(1-(e+1)/t)),this.context.stroke()}))}}class TimeCircleThingy extends ProgressCircleThingy{get total(){return super.name}set total(e){super.total=e,this.targetTime=(new Date).getTime()+1e3*e}start(e){super.start(e);let t=this.context,n=this.canvas;function s(){t.clearRect(0,0,n.width,n.height),t.beginPath(),this.percent=1-(this.targetTime-(new Date).getTime())/(1e3*this.getAttribute("total")),t.arc(n.width/2,n.width/2,n.width/2-15,.6*Math.PI,.4*Math.PI-1.8*Math.PI*(1-this.percent)),t.stroke(),this.targetTime>(new Date).getTime()&&window.requestAnimationFrame((()=>s.call(this)))}window.requestAnimationFrame((()=>s.call(this)))}format(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,"0")}`}
1update(){this.bigText.innerHTML=this.format(this.getAttribute("current")),this.smallText.innerHTML=`/ ${this.format(this.getAttribute("total"))}`,this.percent=this.getAttribute("current")/this.getAttribute("total")}}class ReceivedCircleThingy extends ProgressCircleThingy{start(e){super.start(e),this.waiting=[]}received(e,t=!1){if(t?this.context.strokeStyle=lateColor:this.current++,e in this.waiting&&clearTimeout(this.waiting[e]),this.context.beginPath(),this.context.arc(this.canvas.width/2,this.canvas.width/2,this.canvas.width/2-15,.6*Math.PI+1.8*Math.PI*(e/this.getAttribute("total")),.4*Math.PI-1.8*Math.PI*(1-(e+1)/this.getAttribute("total"))),this.context.stroke(),t)this.context.strokeStyle=goodColor;else if(e>this.painted){let t=latePings.map((e=>e.i));for(let n=this.painted;n<e;n++)t.includes(n)||(this.waiting[n]=setTimeout((e=>{this.context.strokeStyle=badColor,this.context.beginPath(),this.context.arc(this.canvas.width/2,this.canvas.width/2,this.canvas.width/2-15,.6*Math.PI+1.8*Math.PI*(e/this.getAttribute("total")),.4*Math.PI-1.8*Math.PI*(1-(e+1)/this.getAttribute("total"))),this.context.stroke(),this.context.strokeStyle=goodColor}),this.wait,n))}e+1>this.painted&&(this.painted=e+1)}finish(){this.painted+1<document.querySelector("sent-circle-thingy").current&&(this.context.strokeStyle=badColor,this.context.beginPath(),this.context.arc(this.canvas.width/2,this.canvas.width/2,this.canvas.width/2-15,.6*Math.PI+1.8*Math.PI*(this.painted/this.getAttribute("total")),.4*Math.PI-1.8*Math.PI*(1-document.querySelector("sent-circle-thingy").percent)),this.context.stroke(),this.context.strokeStyle=goodColor)}}function setResults(e,t,n){e.querySelector(".percent").innerHTML=0===n?"--":(t/n*100).toFixed(1),e.querySelector(".counts").innerHTML=`(${t} / ${n})`}function setSimpleResults(e,t){if(progress.style.display="none",Array.from(document.querySelectorAll("#simpleResults .result")).forEach((e=>e.style.display="none")),0!==t){const n=e/t;console.log(n),n<.01?document.querySelector(".result.very-good").style.display="block":n<.025?document.querySelector(".result.good").style.display="block":n<.075?document.querySelector(".result.fair").style.display="block":n<.15?document.querySelector(".result.bad").style.display="block":document.querySelector(".result.very-bad").style.display="block"}}if(isSimple||(progress.style.display="block",customElements.define("sent-circle-thingy",SentCircleThingy),customElements.define("time-circle-thingy",TimeCircleThingy),customElements.define("received-circle-thingy",ReceivedCircleThingy),progress.style.display="none"),!Chart)throw new Error("The Chart.js library failed to load.");let chart;function drawChart(e,t,n,s){let i=e.map((e=>null===e?badColor:e<t?goodColor:lateColor));chart&&chart.destroy(),chart=new Chart(document.getElementById("chart").getContext("2d"),{type:"bar",data:{datasets:[{label:document.getElementById("acceptable-delay-term").innerText,data:new Array(e.length).fill(t),type:"line",backgroundColor:badColor+"aa",borderColor:badColor,fill:!1,pointRadius:0},{borderColor:i,backgroundColor:i.map((e=>e+"aa")),label:document.getElementById("response-time-term").innerText,data:e}],labels:[...Array(e.length)].map(((e,t)=>document.getElementById("packet-term").innerText+" #"+(t+1)))},options:{legend:{display:!1},maintainAspectRatio:!1,responsive:!0,scales:{xAxes:[{categoryPercentage:1,barPercentage:1,gridLines:{display:!1},ticks:{display:!1}}],yAxes:[{ticks:{beginAtZero:!0,callback:function(e,t,n){return e+document.getElementById("ms-term").innerText},max:5*Math.ceil(Math.max(Math.min(Math.max(...e),2*t),t,n+2*s)/5)}}]},tooltips:{callbacks:{label:function(e,t){let n=t.datasets[e.datasetIndex].label||"";return n&&(n+=": "),n+=e.yLabel+document.getElementById("ms-term").innerText,n}},position:"custom"}}})}function disableDownloads(){document.getElementById("download-results").classList.add("disabled")}function prepareDownloads(e,t,n,s,i,a,o,r,l,c,d,h,u){let g=[];t.forEach((e=>g[e.i]={id:e.i+1,status:"success",ping:e.ping}));for(let t=0;t<e;t++)if(void 0===g[t]){let e;e=n.includes(t)?"failedOnUpload":"failedOnDownload",g[t]={id:t+1,status:e}}const m=(new Date).toISOString(),p="id,status,ping\n"+g.map((e=>`${e.id},${e.status},${e.ping||""}`)).join("\n");document.getElementById("download-csv").href=URL.createObjectURL(new Blob([p],{type:"text/csv"})),document.getElementById("download-csv").download=`packet-loss-test-results-${m}.csv`;const y=`Total Packet Loss: ${(s/a*100).toFixed(2)}%\nUpload Packet Loss: ${(n.length/a*100).toFixed(2)}%\nDownload Packet Loss: ${((s-n.length)/a*100).toFixed(2)}%\nLate Packet Rate: ${(i/a*100).toFixed(2)}%\n\nAverage Latency: ${o.toFixed(2)}ms\nAverage Jitter: ${r.toFixed(2)}ms\n\nTest Settings:\n  Duration: ${l} seconds\n  Frequency: ${c} pings/second\n  Average Size: ${d} bytes\n  Acceptable Delay: ${h}ms\n  Server Location:  ${u}\n\nDetails:\n--------------\n`;document.getElementById("download-csv-with-summary").href=URL.createObjectURL(new Blob([y+p],{t
1ype:"text/plain"})),document.getElementById("download-csv-with-summary").download=`packet-loss-test-results-${m}.txt`;const f=JSON.stringify({totalPacketLoss:Math.round(s/a*1e3)/1e3,uploadPacketLoss:Math.round(n.length/a*1e3)/1e3,downloadPacketLoss:Math.round((s-n.length)/a*1e3)/1e3,latePacketRate:Math.round(i/a*1e3)/1e3,averageLatency:Math.round(100*o)/100,averageJitter:Math.round(100*r)/100,settings:{duration:l,frequency:c,size:d,acceptableDelay:h},details:g});document.getElementById("download-json").href=URL.createObjectURL(new Blob([f],{type:"application/json"})),document.getElementById("download-json").download=`packet-loss-test-results-${m}.json`,document.getElementById("download-results").classList.remove("disabled")}Chart.defaults.global.elements.point.hitRadius=2,Chart.Tooltip.positioners.custom=(e,t)=>t;
2//# sourceMappingURL=script.terser.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.