2012-04-03 47 views
0

我讀Firefox的配置設置Dom.max_script_run_time什麼是「腳本執行」時間dom.max_script_run_time

http://kb.mozillazine.org/Dom.max_script_run_time

範圍和缺省設置爲10秒。

我的ajax超時也設置爲10秒。

我明白ajax超時計數從發送xmlhttp請求開始,直到響應返回。

但我不確定Firefox的Dom.max_script_run_time是否包含了ajax等待響應的時間。

例如:

1. user click on the button on the web page. 

2. onclick event is triggered (Dom.max_script_run_time start?) 

3. js grag input form data and construct JSON. 

4. Using the JSON string, send ajax request. 

5. main js thread ends. (Dom.max_script_run_time end here???) 

6. xmlHttpRequest object still waiting for the ajax response back from the server. 

7. xmlHttpRequest object receives response from the server. 

8. Display response text on the web page (part of ajax callback) (Dom.max_script_run_time end here???) 

是否Dom.max_script_run_time停在主JS線程結束,因爲AJAX是另一個線程? (即腳本執行是按每個線程定時的?)

回答

1

最大腳本運行時間覆蓋腳本遠離事件循環的時間。這個想法是讓用戶殺掉「掛起」的腳本。

所以,如果你做一個異步XHR,它不應該是一個問題(因爲在你的send()和你的回調觸發瀏覽器是自由處理用戶事件和什麼都不是,因此你的腳本不會看起來「掛起」用戶視角)。

+0

那麼最大腳本運行時間是否在我的問題中的#5處結束? – 2012-04-04 02:36:07

+1

如果我理解你的設置權限(關於「線程」的討論令人困惑,因爲JS只有一個線程,模塊工作者),那麼是的。 – 2012-04-04 05:36:45

+0

啊見。我不知道js只有一個線程。謝謝澄清。 – 2012-04-05 01:51:47

相關問題