-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcachey.html
69 lines (51 loc) · 1.73 KB
/
cachey.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Cachey test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="cachey.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
// Testing Code
$(function() {
var lisToMake = 2500;
console.log($("#test").html());
console.log($("#test").html()); // This selection will be cached
$('<button>')
.html('Select with jQuery()')
.click(function(){
var start = new Date();
for (var i = 0; i < lisToMake; i++){
jQuery('.li' + i).css({background : 'red'});
}
alert(new Date() - start)
})
.appendTo('body');
$('<button>')
.html('Select with $()')
.click(function(){
var start = new Date();
for (var i = 0; i < lisToMake; i++){
$('.li' + i).css({background : 'lime'});
}
alert(new Date() - start)
})
.appendTo('body');
$('<button>', { value : 'arguments', name : 'work'})
.click(function(){
var ul, li, i;
ul = $('<ul>').appendTo('body');
for (i = 0; i < lisToMake; i++){
$('<li>', { class : 'li' + i})
.html(i.toString())
.appendTo('body ul')
}
})
.html('Make a big list!').appendTo('body')
});
</script>
</head>
<body>
<div id="test">hello world</div>
</body>
</html>