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 高效能網站建置指南
74
|
第五章
this.tracker._initData();
this.GAonLoad.apply(this, arguments);
},
_loadGA
函式使用 Script DOM Element 非同步加載技術,它呼叫
dojo.create
建立
script
元素,根據主頁面的協定,將它的
src
屬性設成
http://www.google-analytics.com/
ga.js
https://ssl.google-analytics.com/
,然後把
script
元素附加到文件的 head 元素中。
整合
ga.js
與行內程式碼係透過定時器來完成,每隔
loadInterval
420 毫秒),
_checkGA
會被呼叫,看看
window["_gat"]
Google Analytics 物件)是否被定義。如果
是的話,就呼叫
_gotGA
,實例化 Google Analytics tracker。這項整合技術類似第 55
頁「技術 3Timer(定時器)」所描述的定時器技術。
比較這項實作與
EFWS.Script.loadScript
,可知兩者皆使用Script DOM Element
方法,使用這種技術可以下載指令稿而不阻塞其他資源,並且在所有的主要瀏
覽器上皆可行。然而,這二項整合技術之間也有差異存在,不同於 Timer 術,
EFWS.Script.loadScript
使用的是 Script Onload 技術。Timer 技術存在著幾個缺陷︰
如果指令稿無法載入,定時器將無限期地進行下去。 ...
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