Last active
June 2, 2016 05:30
-
-
Save hushicai/11315775 to your computer and use it in GitHub Desktop.
jsonp memory leak test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>jsonp-memory-leak</title> | |
<meta charset="utf-8" /> | |
</head> | |
<body> | |
<script> | |
function x(data) { | |
// console.log(data); | |
} | |
function loaded() { | |
this.parentNode.removeChild(this); | |
this.onload = null; | |
} | |
var interval; | |
function start() { | |
var script = document.createElement('script'); | |
var id = script.id = 'script_' + (+new Date).toString(36); | |
script.src = 'http://localhost:3000?callback=x'; | |
script.onload = loaded; | |
document.head.appendChild(script); | |
// cycle | |
//document.getElementById(id).expando = script; | |
//script.bigString = new Array(1000).join('xxx'); | |
} | |
function loop() { | |
interval = setInterval(start, 100); | |
} | |
function stop() { | |
clearInterval(interval); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment