views:

89

answers:

1

I learned web applications in the old days before there were Javascript libraries and web application frameworks. When I find time (which might not happen), I wouldn't mind updating my experience with these more modern methods. However, if I did write a web page with one of these modern packages, I wouldn't want to slam together something that's too modern for many of the browsers of the user base.

This brings me to some behavior that I have noticed on several web sites with relatively slick Javascript effects. One site where it's been a problem is the Davis Vanguard blog, which uses Joomla 1.5. Another is MathOverflow. The most serious problem is that often I when I do something relatively simple, my laptop freezes for a few seconds, long enough to make the UI feel icky rather than slick. In the Davis Vanguard site, all it takes to see it is scrolling from top to bottom in one of the discussion pages. In MathOverflow, it usually happens when I'm typing an answer in the answer box. But it is also possible, maybe, to create a few-second hang even just scrolling on a popular question page. (This is after the jsMath has rendered.)

I am running Ubuntu 8.04 on my laptop and Firefox 3.0.19. One clue about the problem is that when it happens, the system clock freezes along with the Firefox session. It makes me wonder whether jQuery or Joomla or something is causing a DNS lookup now and then. Of course, I could upgrade my own system to something more modern, and maybe I should. But that might not be much of a solution if I wrote a web site for other people to use.

The more general question is, if I want to use a spiffy Javascript library but I also want to avoid this sort of pitfall --- gratuitous UI delays, rendering errors, etc. --- what should you do? Is jQuery better than MooTools? Is it a matter of using the Javascript library in the right way, or avoiding certain bleeding edge functions? Is it truly that Ubuntu 8.04 are behind the times? Is it because Chrome has much better Javascript support than Firefox? Or should I blame DNS as provided by Comcast?

+2  A: 

To get one quibble out of the way immediately: Joomla isn't a JavaScript library. It's a PHP-based CMS and isn't strictly tied to any particular JavaScript framework. On a cursory glance, I don't notice any JavaScript being executed as I scroll down Davis Vanguard's blog.

DNS issues seem extremely unlikely: scripts are often hosted on the same domain as the site, and even when they aren't, DNS caching would eliminate any issue after a single page load.

Firefox for Linux is a port; it has performance issues when compared to the Windows edition. An underpowered laptop will just compound the problem.

There are some benchmarks on the web comparing performance of the popular JS frameworks. I think the only way to find out if your own laptop can handle certain features of a library is to test them.

BipedalShark
Greg Kuperberg
Also, if DNS is unlikely, I don't disbelieve you, but what kind of browser slowdown would interrupt multitasking? (Again, it's a Dell XPS from 2008, and I am not talking about anything that causes disk thrashing.)
Greg Kuperberg
Depending on Firefox version, synchronous XHR can cause the entire Firefox GUI to lock up until the request finishes--though I don't see this happening on the first or second davisvanguard.org link.Have you tried building the latest Firefox version from source? Mozilla has been constantly patching memory leaks throughout Firefox's history. Additionally, Firefox has a new JavaScript engine ("Tracemonkey") as of 3.1; it makes for quite a speedup.
BipedalShark
Your answer is getting more and more interesting with each remark. So (1) can something like an XHR request lock not just Firefox, but the entire desktop, include the Gnome clock? (2) You're tending to blame my Firefox, even though an older Firefox on an older Ubuntu at work has fewer hangs. Maybe that's what I should generally blame? (BTW, I had the good fortune to witness another 5-second hang, gnome panel clock included, while typing this comment in SO.)
Greg Kuperberg
And I agree that I should try Firefox 3.1, haven't done that yet.
Greg Kuperberg
I'm not sure about (1) on Gnome. At http://bit.ly/9AxyxL is a page making a synchronous XHR call every second. Each call will take 0.5 seconds (plus network latency) to complete, so it should give you enough time to see what freezes--if anything. In the latest version of Firefox, even keystrokes made in the textarea will be ignored during requests. As for (2), it was indeed a later patch (I don't recall which) to Firefox 3 that caused synchronous XHR calls to freeze the entire GUI.
BipedalShark
When I try your XHR call page, it says "Access to restricted URI denied". But by the way, what is the easiest way to see these locking requests when Firefox tries to make them? (Looks like Firebug might be an answer to that question?)
Greg Kuperberg
Try again with the page. To see XHRs, Firebug will definitely do the trick, but there are also iframes (which may make their XHRs). The "Tamper Data" plugin is a tool to use to see all HTTP requests.
BipedalShark
It works now, I guess, and thanks for setting that up for me. But at the moment it looks like HTTP requests aren't the problem. But maybe the whole thing isn't really a development question and for whatever reason is a Firefox question.
Greg Kuperberg