I’ve been working on a project (Javascript with some AJAX, JQuery, etc) and my project has gotten rather large; I’m finding myself using more and more clientside Javascript arrays, and am now considering a 2D Javascript array as well.
I know from incremental testing that my current implementation is very much manageable in terms of browser resources and performance, but was wondering if there was a general consensus as to how “heavy” a website could be in terms of Javascript memory usage and processing before it could be declared “bloated.”
Also, if I’m already treading into dangerous territory by using this much storage and processing (I feel like I’m coding a rather substantial Java/C app), what is the best way to lighten the load?
Thanks!
One man’s “bloated” is another man’s “robust”. In other words, there is no “right” answer to this question, as it depends heavily on your audience and your site. For some sites, every millisecond of load time matters, while for others a 20 second load time is perfectly acceptable. It really just depends.
The best advice that I can suggest is to use one of the many site performance analysis tools (eg. YSlow) to get a sense of just how slow your app actually is. These tools can also give you a better idea of what is making your site slow; for instance, you might think it’s the amount of JS code you have, but really the number of JS files (every HTTP request has a cost) might be the bigger factor.
Once you have some objective, metricable sense of how slow your site is, you can then take the time to consider your audience and determine how slow is “too slow” for them. And once you’ve done that, you can then consider all of the different suggestions that YSlow (or whatever tool you choose) offers, and pick which ones (if any) make the most sense for your site.