Last active
October 18, 2017 11:48
-
-
Save flying-sheep/fa598de4816dc49598b0168cbc938544 to your computer and use it in GitHub Desktop.
script insertion and stack traces. jQuery’s magic is bad for debugging
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
license: mit |
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> | |
<head> | |
<meta charset=utf-8> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
<script> | |
const script = src => { | |
const node = document.createElement('script') | |
node.src = src | |
return node | |
} | |
$(() => { | |
$('head').append(script('test-jquery.js')) | |
document.head.appendChild(script('test-native.js')) | |
}) | |
</script> | |
</head> | |
<body> | |
jQuery: | |
<pre id=jquery></pre> | |
native: | |
<pre id=native></pre> | |
</body> |
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
function bluh() { | |
throw new Error('where am I?') | |
} | |
try { | |
bluh() | |
} catch(e) { | |
document.querySelector('#jquery').textContent = e.stack.toString() | |
} |
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
function bluh() { | |
throw new Error('where am I?') | |
} | |
try { | |
bluh() | |
} catch(e) { | |
document.querySelector('#native').textContent = e.stack.toString() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment