Use JavaScriptLint / JsLint / JSure , map as External Tool or as a PostBuild command to find quickly find syntax errors
Decorate web services with [ScriptService] attribute to be able to call from script
No snippet support for JS
No function browsing as for cs/aspx/... files
Editing huge JS files like the ext-all-debug.js (35k lines) is a disaster in VS, there are other alternatives (Aptana Studio, JsEclipse)
Debugging efficiently
Use the debugger; keyword in your JavaScript files
Use Fiddler (if nothing turns up in the log use localhost. or computer name for IE7)
Fiddler works for FF too ( by modifying proxy settings )
Fiddler plugins : JSONViewer , SyntaxView
Use FireBug - plugins YSlow , FireCookie etc
IE developer toolbar - features ”Disable script”, ”Disable cookies” etc
CustomErrors property in web.config controls if callstack is included in web service exception
Get a ”view rendered source” plugin, for Firefox and for IE
What is ExtJS?
What is ExtJS?
Including the full Ext library minified (not GZIPped) means around 550kb of JS and 80kb CSS
Also simplifies DOM-operations & event handling etc, though if that is the only thing you need you can find smaller libraries that fit your purpose better. Jquery weighs in at 15kb (minified and GZIPped)
Using the [ScriptMethod(ResponseFormat = ResponseFormat.Xml/Json)] doesn’t always seem to produce the expected result. How you pass parameters to .NET control how the data is being served
If you want JSON data in your widgets, create a custom HttpProxy to get the parameters json encoded
If returning data as DataTable/DataView/DataSet create custom a JavaScriptConverter to avoid circular reference issue .
Remember to set the root property of the JsonReader
Create override to handle MS JSON date format
Watch out for the maxJsonLength attribute in web.config, default value is 102400 characters
Same origin policy applies to XHR requests. Can be resolved by using ScriptTagProxy, see Ext forums.
Watch out for saving state in cookies using Ext.state.CookieProvider, Ext auto-generates component id’s
Error handling in Ajax/Ext apps
When data doesn’t load as expected, first determine where the error is occurring (client or server) by using Fiddler/Firebug.
When using web services you loose the functionality of Application_Error in global.asax
To be able to log errors and control what’s being sent over the wire, you could either
Wrap each web service call in try/catch blocks, lots of extra code
Use an AOP library(for example PostSharp AOP ) to inject the try/catch code at compile time
Catch & Log JavaScript errors using window.onerror. Check PDF by Nicholas Zakas on Enterprise JavaScript Error Handling. window.onerror does not catch the ”Operation aborted” error if you modify the DOM too early.
Follow the tips from Yahoo Exceptional Performance team and use Yslow
Use script combining, minification ( YUICompressor ) and GZIP
Web service output can be GZIPped as well, test in Fiddler by setting Rules->Apply GZIP encoding
Use caching, make sure right versions of js/css files are being served. Append version number or last file write date.
Be aware of memory usage, Ext can be heavy on memory. IE6/IE7 have memory issues, use Drip/SIEve to track memory leaks. Lots of information on this in Ext Forums
Conclusions
Not using the ASP.NET Page model anymore. Remember to disable viewstate. Pages without any .NET controls could be changed to static HTML pages instead.
You don’t have to use pages anymore, new apps could use Single Page Interface pattern for maximum performance. History/back-button and bookmarking is harder though.
0 comments
Post a comment