Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (37 sloc) 1.45 KB
<!doctype html>
<title>Case-Hardened JavaScript Tests</title>
<p>Making sure some of the assumptions I've made about my new framework are true.</p>
<li>Hard-coded <code>script</code> tags always work, since they show up before <code>window.onload</code> fires.</li>
<li>Dynamically-created <code>script</code> tags work, if they are created before <code>window.onload</code> fires.</li>
<li>Dynamically-created <code>script</code> tags do NOT work if they are created AFTER <code>window.onload</code> fires.</li>
var b = document.createElement('BUTTON');
b.innerHTML = 'Click to add a button.';
b.onclick = function() {
// dynamically create a NEW instance of stub.js
var s = document.createElement('SCRIPT');
s.src = 'stub.js';
// settings is a non-existant attribute, so Firefox will want us to use setAttribute and not just s.settings='foo'
s.setAttribute('settings', 'exe=1');
// exe=set means "run me immediately."
// this should NOT work, since it's firing after the window loads, without
// setting exe
window.onload = function() {
var s = document.createElement('SCRIPT');
s.src = 'stub.js';
<!-- this should always work -->
<script src="stub.js"></script>
Something went wrong with that request. Please try again.