测试 浏览器 loading 标志
测试 浏览器 loading 标志
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
var express = require("express") | |
, app = express() | |
app.set('views', __dirname) | |
app.set('view engine', 'jade'); | |
app.get("/domready", function(request, response) { | |
response.render("domready"); | |
}) | |
app.get("/set_timeout", function(request, response) { | |
response.render("set_timeout"); | |
}) | |
app.get("/set_timeout_and_domready", function(request, response) { | |
response.render("set_timeout_and_domready"); | |
}) | |
app.get("/sleep_five", function(request, response) { | |
response.setTimeout(5000, function() { | |
response.contentType("text/javascript"); | |
response.send('console.log(1)'); | |
}) | |
}) | |
app.listen(3001) |
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
html | |
head | |
title - My | |
script(type='text/javascript'). | |
(function (fn) { | |
var listener | |
, doc = document | |
, domContentLoaded = 'DOMContentLoaded' | |
, loaded = /^loaded|^i|^c/.test(doc.readyState); | |
if (!loaded){ | |
doc.addEventListener(domContentLoaded, listener = function () { | |
doc.removeEventListener(domContentLoaded, listener) | |
loaded = 1 | |
fn() | |
}); | |
} else { | |
fn() | |
} | |
})(function () { | |
var global = window; | |
var newNode = global.document.createElement('script') | |
, existingNode = global.document.getElementsByTagName('script')[0] | |
newNode.setAttribute('type', 'text/javascript'); | |
newNode.setAttribute('src', '/sleep_five'); | |
newNode.setAttribute('async', true); | |
existingNode.parentNode.insertBefore(newNode, existingNode); | |
}); |
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
html | |
head | |
title - My | |
script(type='text/javascript'). | |
setTimeout(function(){ | |
var global = window; | |
var newNode = global.document.createElement('script') | |
, existingNode = global.document.getElementsByTagName('script')[0] | |
newNode.setAttribute('type', 'text/javascript'); | |
newNode.setAttribute('src', '/sleep_five'); | |
newNode.setAttribute('async', true); | |
existingNode.parentNode.insertBefore(newNode, existingNode); | |
}, 0) |
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
html | |
head | |
title - My | |
script(type='text/javascript'). | |
(function (fn) { | |
var listener | |
, doc = document | |
, domContentLoaded = 'DOMContentLoaded' | |
, loaded = /^loaded|^i|^c/.test(doc.readyState); | |
if (!loaded){ | |
doc.addEventListener(domContentLoaded, listener = function () { | |
doc.removeEventListener(domContentLoaded, listener) | |
loaded = 1 | |
fn() | |
}); | |
} else { | |
fn() | |
} | |
})(function () { | |
setTimeout(function() { | |
var global = window; | |
var newNode = global.document.createElement('script') | |
, existingNode = global.document.getElementsByTagName('script')[0] | |
newNode.setAttribute('type', 'text/javascript'); | |
newNode.setAttribute('src', '/sleep_five'); | |
newNode.setAttribute('async', true); | |
existingNode.parentNode.insertBefore(newNode, existingNode); | |
}, 0) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment