views:

37

answers:

1

I use jQuery 1.4 for AJAX, MVC on the server side. Everything works fast on the local computer. Tables with data are compiled and sent as HTML documents (I’m testing the system with large tables, over 100KB). When I download the same page through the internet, everything works 5-10 times slower or is simply pending.

I checked Forefox debugger. AJAX sent the query and received the data quickly (I can see the received response with the correct data). But then it inserts the data in DOM very slowly, the following instruction works particularly slowly: $("#oldtable").replaceWith( newtable ); and empty() It works extremely slowly in IE6,8 (3 sec on local machine and about 1 min through the internet). I delete the data from DOM as one object and insert the whole table. There are no errors in the inserted html code.

Please could you recommend how to make it work faster? Probably I should use another library, such as Prototype. I can’t understand the following: Javascript is executed on the client’s side, the data is already uploaded. The computer is the same. Why does execution time differ so much? Thank you, Igor

A: 

Many issues here:

1) For fast inserting and emptying data, jquery is sometimes slower than straight javascript functions like .innerHTML. Even though these functions are not part of the standard, sometimes their fast performance makes them attractive.

2) jquery is javascript, so it runs on the client. Unless your .js files are REALLY large, it shouldn't make much difference if you download them from the localhost or a server on the internet.

3) AJAX functions are requests to the server. So, it makes a big difference if you are downloading large amounts of data from the localhost vs. server.

Ralph Stevens