views:

258

answers:

6

Recently i was asked

(1) "How will you do performance optimization over your jQuery in ASP.net ?"

(2) "How many script manager can we have in ASP.net Application?" why? (Ajax related).

I have no ideas on both.Help me to grow.

+1  A: 

I am also not sure on what to answer for question #2, but I can give some thing for question #1

If you were not able to answer question #1 means that you have a fairly less idea about JQuery, I suggest learning JQuery to a fair extent first.

Coming to the question, there are a lot of things that you can do to optimize your JQuery, like while coding it you can follow the tips mentioned in the following links :

http://jonraasch.com/blog/5-performance-tuning-tricks-for-jquery

http://jonraasch.com/blog/10-advanced-jquery-performance-tuning-tips-from-paul-irish

Mahesh Velaga
How is it possible to answer question #1 if it's incorrect? What does jQuery have to do with ASP .Net?
HeavyWave
The main thing that is looked in is JQuery, and no where in answer I mentioned that it is specific to ASP.NET
Mahesh Velaga
+1  A: 

Regarding (1)

  1. Use tools like firebug or dynatrace to do the profiling and digging the code.
  2. JQuery is not out of nowere its JavaScript so one has to know it well for optimization.
  3. Adhere to good JavaScript coding practices that helps big time.
  4. Always remember that each JS file and line of code you write is transfered to client for execution so be aware of it while writing code as this cas cause issues. So if you decide to include 4 JS file sum sized to 400 KB emans u are putting burdon on the client especially if he is on slow lines.

Yes and for (2) refer http://forums.asp.net/t/1073734.aspx link. One page can only have one script manager. Hope that helped :)

Anil Namde
A: 

You can have only one ScriptManager per page

Amitabh
application != page
mxmissile
A: 

A page can contain only one script manager in its hierarchy according to the documentation. For jQuery optimization, it is important to use minified versions of all JS files and profiling tools such as Firebug are helpful.

Kevin Sylvestre
+3  A: 

You can only have one ScriptManager on a page. The script manager has several responsibilities, such as loading the MS Ajax libraries, creating proxy classes for web services, and enabling partial page rendering (e.g. UpdatePanel) support. It doesn't make sense to have more than one per page, and you'll get an exception if you try to do this.

If you need to load additional scripts or references, in a user control for example, you can use the ScriptManagerProxy class.

richeym
A: 
  1. Watch your selectors, especially when you are working with .NET. You don't want to run the same selector multiple times. Instead you would want to define a javascript variable to hold the selector and then use that variable...that way jQuery is not having to find the same selector multiple times.

  2. You can have 1 ScriptManager per page.

Erikk Ross