views:

5068

answers:

6

We've got a page with a ton of jQuery (approximately 2000 lines) that we want to trim down b/c it is a maintenance nightmare, and it might be easier to maintain on the server. We've thought about using UpdatePanel for this. However, we don't like the fact that the UpdatePanel is sending the whole page back to the server.

Looking for suggestions.

+2  A: 

Is there a way to modularize your jQuery code?

Eldila
+4  A: 

I don't know if there is a way to optimize UpdatePanels, but my company has found its performance to be pretty poor. jQuery is much much faster at doing pretty much anything.

There can be a lot of lag between the time when an UpdatePanel triggers an update and when the UpdatePanel actually updates the page.

The only reason we use UpdatePanels is because of the ease of development. Almost nothing needs to be done to make them work.

Dan Herbert
A: 

What are you using jQuery for? It could be easier to roll your own Ajax solution if that's all you're doing.

Are there parts of your website that don't have to use Ajax, but currently are? Removing the non-essential Ajax calls would cut down on your code tremendously.

Srdjan Pejic
A: 

Have you seen chain.js? It automates binding data to your html, which may help you reduce some of your code.

Adam Lassek
+24  A: 

Don't move to UpdatePanels. After coming from jQuery, the drop in performance would be untenable. Especially on a page as complex as yours sounds.

If you have 2,000 lines of JavaScript code, the solution is to refactor that code. If you put 2,000 lines of C# code in one file, it would be difficult to maintain too. That would be difficult to manage effectively with any language or tool.

If you're using 3.5 SP1, you can use the ScriptManager's new script combining to separate your JavaScript into multiple files with no penalty. That way, you can logically partition your code just as you would with server side code.

Dave Ward
+7  A: 

Hi Macho Matt.

Please don't put your self in that world of pain. Instead use UFRAME which is a lot faster and is implemented in jQuery.

Now, to manage those 2000 lines of Javascript code I recommend splitting the code in different files and set up your build process to join them using JSMin or Yahoo Compressor into chunks.

Cheers.

Julio César