Home Web Front-end JS Tutorial How to test the opening response speed of the target website using JS

How to test the opening response speed of the target website using JS

Dec 12, 2017 am 10:26 AM
javascript Open

I used JS to write a simple tool to test the opening speed of a directory website. Note that this is only the speed of opening a directory website on this machine. It does not mean that other users will open it at the same speed. In fact, it can also be used to test the speed of the local network. This article briefly explains how to use JS to test the opening response speed of the target website. The method is simple and clear for everyone to understand at a glance. I hope it can help everyone.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
</head>

<body bgcolor="transparent" style="color:#FFFFFF;">
<style type="text/css">
input{font-size:12px;padding:0 5px;line-height:21px; font-family:tahoma;border:1px solid #ccc;height:21px;}                        </style>
<script language="javascript">
tim=1
setInterval("tim++",100)
b=1
var autourl = new Array();
autourl[1] = "www.qq.com";
autourl[2] = "www.jb51.net";
autourl[3] = "www.baidu.com";
autourl[4] = "www.sina.com";

function butt(){
document.write("<form name=autof style='padding:0px; margin:0px;'>")
for (var i = 1; i < autourl.length; i++) document.write("<input type=text name=txt" + i + " size=25 style='color:#999;' value=测试中…> =》<input type=text name=url" + i + " size=40> =》<input type=button value=GO onclick=window.open(this.form.url" + i + ".value)><br>")
document.write("<input onclick='window.location.reload()' type=submit value='刷新' style='margin-top:10px'></form>")
}
butt()
function auto(url){
document.forms[0]["url"+b].value=url
if(tim>200)
{document.forms[0]["txt"+b].value="网址"+b+"链接超时"}
else
{ document.forms[0]["txt" + b].value = "网址" + b + ": 访问速度" + tim * 10 + "ms" }
b++
}
function run(){for(var i=1;i<autourl.length;i++)document.write("<img src="+autourl[i]+"/"+Math.random()+" width=1 height=1 onerror=auto('"+autourl[i]+"') style='display:none'>")}
run()
</script>
</body>
</html>
Copy after login

The network environment of each computer is very complex, so the value obtained by this script is for reference only.

Related recommendations:

Detailed explanation of using memcache caching technology in PHP to improve response speed_PHP tutorial

JS Testing and Access CI Guide

Summary and recommendation of HTML 5 special effects page and js test page

The above is the detailed content of How to test the opening response speed of the target website using JS. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to open iso file on mobile phone How to open iso file on mobile phone Feb 24, 2024 pm 05:33 PM

How to open iso file on mobile phone

Can I open an XML file using PowerPoint? Can I open an XML file using PowerPoint? Feb 19, 2024 pm 09:06 PM

Can I open an XML file using PowerPoint?

Share the method to solve the problem that PyCharm cannot be opened Share the method to solve the problem that PyCharm cannot be opened Feb 22, 2024 am 09:03 AM

Share the method to solve the problem that PyCharm cannot be opened

How to open torrent files How to open torrent files Feb 24, 2024 pm 05:20 PM

How to open torrent files

How to open caj file How to open caj file on computer How to open caj file How to open caj file on computer Feb 22, 2024 pm 04:37 PM

How to open caj file How to open caj file on computer

Where can I open the Douyin mini game? Two ways to open Douyin mini games Where can I open the Douyin mini game? Two ways to open Douyin mini games Mar 15, 2024 am 09:30 AM

Where can I open the Douyin mini game? Two ways to open Douyin mini games

How to open a file with .vsd suffix How to open a file with .vsd suffix Feb 18, 2024 pm 08:28 PM

How to open a file with .vsd suffix

Slack: This link cannot be opened Slack: This link cannot be opened Feb 19, 2024 pm 09:20 PM

Slack: This link cannot be opened

See all articles