File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Performance issues with javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Performance issues with javascript" Watch "Performance issues with javascript" New topic
Author

Performance issues with javascript

sushil bharwani
Greenhorn

Joined: Mar 02, 2006
Posts: 26
I have few questions regarding performance issues with javascript:

if a jsp code contains lots of javascript methods which are not in use is that a performance issue?

what is better in terms of performance writing code in .js file and loading the file or writing code in the .jsp file itself.

what is heavy in terms of performance a div or a table or a p tag.

what other areas can/should be considered for javascript performance tuning
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
Putting the js into a seperate file is normally better since it gets cached.

You probably would want to look into this: http://dean.edwards.name/packer/

===

Tables render slower than divs/spans. Plenty on information out there with the a google search.


===

Some performance tips

http://blogs.msdn.com/ie/archive/2006/08/28/728654.aspx

Eric
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35224
    
    7
if a jsp code contains lots of javascript methods which are not in use is that a performance issue?

There is a tiny performance hit, but in all likelihood it's much too small to be worth contemplating.

what is better in terms of performance writing code in .js file and loading the file or writing code in the .jsp file itself.

If you have it as part of the page it gets generated and sent every time the page is accessed. On the other hand, if you keep it in a separate file you save that effort on the server, because the browser will cache it as long as it's unchanged - much better.
[ February 05, 2008: Message edited by: Ulf Dittmer ]

Android appsImageJ pluginsJava web charts
sushil bharwani
Greenhorn

Joined: Mar 02, 2006
Posts: 26
I appreciate your suggestion,

But a question to eric, you have provided a link to Dean Edwards Packer;

What this does primarly is it removes whitespaces and change the names of variables to a smaller/shorter name does this helps performance ... ?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
It shrinks the js file size which means it is a quicker download.

Eric
 
jQuery in Action, 2nd edition
 
subject: Performance issues with javascript
 
Similar Threads
Disadvantages of Servlets
Bugs with parameters escape
Performance and JSP include...
Looking for a javascript-debugger as a plugin for eclipse
JSP load time performance if there are lot of JS coding