I want to do some tests for JavaScript code that is launched before document is completely loaded and after that.
开发者_运维问答Is there any posibility to delay in own document loading (fo 10 seconds, for example)? So I will clearly see when there is effects done BEFORE document was loaded and AFTER.
Thanks.
Would be greate to have a cross-browser solution.
Firefox Throttle could help you slow down the loading of the page and might give you what you're looking for.
For me, 100.000 paragraphs (<p>Test</p>
) did the work. Firefox 9.0 is occupied for some seconds.
One way to do this is to simply slow down all incoming traffic to your machine, by setting the max bandwidth to some v. small value e.g. a few KB per second. If you then host your file on a web server and hit the external URL to obtain it (the web-server can be running on you dev machine, you just need to remember to use the external URL for the file rather than via localhost
or 127.0.0.1
). The nice thing about this is that it's cross-browser by default.
I'm not sure what the code is on Windows or Linux but if you're using Mac OS X you can use the following code to set the download rate to 2kB/second:
sudo ipfw pipe 1 config bw 2KByte/s
sudo ipfw add 100 pipe 1 tcp from any to me 80
Then when you're finished testing do:
sudo ipfw delete 100
to take the restriction off.
Note: I can't really take credit for this code as it's based on the example from Jonathan Stark's book.
精彩评论