1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
---|
5 | <title>setInterval leak in fx</title> |
---|
6 | <style type="text/css"> |
---|
7 | #div1 {position:absolute;left:300px;top:0;background-color:red;width:100px;height:100px} |
---|
8 | </style> |
---|
9 | <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.js"></script> |
---|
10 | <script type="text/javascript"> |
---|
11 | $(function(){ |
---|
12 | for(var i = 6; i > 0; i--) { |
---|
13 | $('p').clone().appendTo(document.body); |
---|
14 | } |
---|
15 | $(window).bind('scroll resize', function() { |
---|
16 | $('#div1').stop() |
---|
17 | .animate({ |
---|
18 | 'top': $(window).scrollTop()+ 100 |
---|
19 | }); |
---|
20 | }); |
---|
21 | }); |
---|
22 | </script> |
---|
23 | </head> |
---|
24 | <body> |
---|
25 | <p>Scroll the document up and down crazily and observe CPU usage</p> |
---|
26 | <p>Profiling using Firebug shows setInterval leak</p> |
---|
27 | <div id="div1"></div> |
---|
28 | </body> |
---|
29 | </html> |
---|