Skip to Main Content
高效能網站建置指南
book

高效能網站建置指南

by Steve Souders
January 2013
Intermediate to advanced content levelIntermediate to advanced
280 pages
5h 38m
Chinese
GoTop Information, Inc.
Content preview from 高效能網站建置指南
64
|
第五章
EFWS.Script.loadScriptXhrInjection("menu.js", null, true);
EFWS.Script.loadScriptXhrInjection("menutier.js", init, true);
</script>
第一次呼叫
EFWS.Script.loadScriptXhrInjection
載入
menu.js
並且保持執行順序,第 2
次呼叫促使
menutier.js
被下載,也是指定按順序下載,而且傳進
init
當作這個指令稿的
onload
函式。
如圖 5-5 所示,這個範例的 HTTP 瀑布圖顯示一段較短的 HTML 文件請求,隨後接著對
頁面裡 3 個資源的請求︰
menu.js
(兩秒回應)、
menutier.js
(一秒回應),以及圖像(一
秒回應)。頁面裡所有資源並行加載,而且執行順序被保持(沒有未定義符號的錯誤
出現)。
文件
menu.js
menutier.js
圖像
5-5 Managed XHR HTTP 瀑布圖
Managed XHR 跨所有主要瀏覽器解決了這個問題,然而,鑒於
XMLHttpRequest
的同源
政策(same-origin policy
3
規則,假如外部指令稿與主頁面存在於不同的網域,這項技
術就無法生效。另一方面,DOM Element and Doc Write 技術適用於指令稿與主頁面位
在不同網域時的狀況。
DOM Element Doc Write
Managed XHR 技術非常適用於依特定順序加載外部與行內指令稿的狀況,並且不會阻 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

初探深度學習|使用TensorFlow

初探深度學習|使用TensorFlow

Reza Zadeh, Bharath Ramsundar
優雅的SciPy|Python科學研究的美學

優雅的SciPy|Python科學研究的美學

Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow

Publisher Resources

ISBN: 9789862766583