JQuery Templates and Best Practices in Asp.net MVC 3.0

I am working with an Asp.net MVC 3.0 application and use jQuery + JSON. I plan to use jquery post and get methods for sending / returning data to the server. As a result, my jQuery Code base will be large and should be supported.

so what are the best practices and design patterns when using jQuery with ASP.net MVC 3.0?

+4
source share
1 answer

Here are some suggestions:

  • Always try to place javascript in separate js files and not place them in views.
  • Never print urls in javascript files. Always use Url helpers when creating URLs.
  • For javascript code that can be reused in multiple places, prefer writing a jQuery plugin.
  • Before writing any code, find out if anyone else has added a jQuery plugin for it.
  • Minimize your javascript files when working in release mode
  • Try reducing the number of AJAX requests: for example, prefer a single AJAX request that sends / receives large data compared to multiple AJAX requests with less data.
+4
source

All Articles