File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Does your book address these? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Does your book address these?" Watch "Does your book address these?" New topic

Does your book address these?

kumar naresh
Ranch Hand

Joined: Mar 12, 2011
Posts: 120
Usually there is a complaint about performance while rendering huge data in the browser when compared with server side code while loading a page. Do you suggest any best practices in this regard?

Do you suggest any design patterns and/or best practices to follow while coding javascript?

JS has to be written based on browser complaint sometimes, some code doesn't work in IE but works in Chrome. Are there any ways to get ride of browser specific code and make it work on any browser let it be mobile/tablet browser as well?


Elisabeth Robson
Ranch Hand

Joined: May 14, 2004
Posts: 173
Hi Kumar,
Our book doesn't cover any of the topics you've identified, because it focuses on the fundamental language concepts.

However, all of the topics are important to learn about!

1) Performance is definitely an issue. There are a couple of things you can do. One is to request chunks of data at a time using XHR (Ajax) from the server, if it's the case that your data can easily be split up into chunks and processed on the client a bit at a time. That way, the client doesn't have to wait until all the data is downloaded to be responsive to the user.

You can also cache your data using local storage. All modern browsers support local storage now, and loading it from the local browser is going to be faster than downloading it from the network. Some have complained that local storage is not as fast as it should be, so you'll want to do some performance testing and compare it to say, using the file api, using the network, or even a database solution (although those are not as widely supported).

Once your data is loaded, if you need to process data speedily, take a look at the web workers API for splitting up the processing across multiple workers. Most people have multi-core computers now, and you can get a big boost in your UI responsiveness with big data using web workers. For instance, for Head First HTML5 Programming, we used web workers to process fractal data, and the results were pretty amazing.

2) There are lots of best practices for coding JavaScript. One pattern we use in the book (although we don't call it out specifically as a pattern) is the Model-View-Controller pattern, which is helpful for splitting up the concerns of a program. Another pattern that is used frequently in JavaScript is the module pattern, which allows you to create modules of code. We show one example of this in the book (again, without calling it out specifically as a pattern), but we don't go into it in depth at all. However, you learn everything you need to know in the book in order to understand the pattern, so you can go tackle that on your own.

3) I agree, cross-browser issues are a pain, and always will be as long as browsers continue to innovate each in their own direction. However, as far as the core language is concerned (not API support, for instance), all modern browsers are all pretty much equivalent now (as of IE10). Which is great news! That said, using libraries that provide shims or polyfills for back compatibility and cross-browser compatibility can really help. There are several mobile libraries that can help with this for mobile sites, too.

Hope that helps!


Co-Author of Head First JavaScript Programming
kumar naresh
Ranch Hand

Joined: Mar 12, 2011
Posts: 120
Thank you for the response.

I agree. Here's the link:
subject: Does your book address these?
It's not a secret anymore!