Skip to content

Commit

Permalink
提交bigpipe的修改
Browse files Browse the repository at this point in the history
  • Loading branch information
mazidong committed May 22, 2017
1 parent 4bf127e commit 5e42d26
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
Empty file added H5/01-webWorker/ReadMe.md
Empty file.
13 changes: 13 additions & 0 deletions H5/01-webWorker/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<title>webworker</title>
</head>
<body>
<div>
<button id="btnClick">Click me!</button>

</div>
<script src="./index.js"></script>
</body>
</html>
17 changes: 17 additions & 0 deletions H5/01-webWorker/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var $ = function(_){
return document.querySelector(_);
}, myWorker;

if (window.Worker) {
myWorker = new Worker('worker.js');
}

$('btnClick').onclick = function(){
if (!myWorker) return;

myWorker.postMessage(['first', 'second', 'third', 'fouth']);
}

myWorker.onmessage = function(e) {
console.log('Receive 数据了');
}
5 changes: 5 additions & 0 deletions H5/01-webWorker/worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
onmessage = function(e) {
console.log('webwork接受到数据了', e);

postMessage({a:"fasdfadf", b:"fasdfasdfasdf"});
}
15 changes: 5 additions & 10 deletions performance/bigPipe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@ http.createServer(function(req, res) {
* **/
//res.writeHead(200, {'Content-Type':'text/html', "Content-length":9})

res.writeHead(200, {'Content-Type':'text/html'})
res.write("<div>hello world!!!</div><img src='http://www.baidu.com/img/bd_logo1.png' />");
res.writeHead(200, {'Content-Type':'text/html', "Keep-Alive":"timeout=5"})
res.write('<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><div>hello world!!!</div><img src="http://www.baidu.com/img/bd_logo1.png" />');

setTimeout(function() {
res.write("<div>hello world222!!!</div>");

setTimeout(function() {
res.write("<div>hello world333!!!</div>");
res.end();
}, 5000);
}, 5000);
setInterval(function() {
res.write("<div>hello worl!!!" + Math.random() + "</div>");
}, 1500);


}).listen(8888, function(){
Expand Down

0 comments on commit 5e42d26

Please sign in to comment.