Reputation: 10575
Right now I am using jQuery completely for my project (ajax, validations). But I guess due to my statements I assume that it is taking more time and how can I optimize the time for execution of each statement? Say for example I have seen some posts in Stackoverflow saying this statement:
$("div#mydialog").bind('Dialogclose',function(){});
is much slower than this:
$("#mydialog").bind('Dialogclose',function(){});
How can I attain this conclusion? Do I have S Tools for this? How can I optimise the statements in jQuery? What are the best practices to be used in jQuery?
Upvotes: 5
Views: 578
Reputation: 11651
Try running your pages with the FireQuery FireFox extension.
http://firequery.binaryage.com/
FireQuery allows you to inject jQuery Lint (https://github.com/jamespadolsey/jQuery-Lint) into a page, giving you information on jQuery errors and incorrect usage.
You can also use a JavaScript profiler, such as FireBug in FireFox, the IE Developer Console in IE8 or higher, Developer Tools in Chrome, etc. This will give you execution times in each browser which can then be optimized.
Upvotes: 1
Reputation: 74360
Why not use the PROFILE jquery plug-in from plugins.jquery.com, which was made for just this purpose: PROFILE jquery plug-in
Upvotes: 5