Best Approach to Develop a Cross-Browser JavaScript App

browser-compatibilityjavascript

As one of my summer projects I'd like to build an AJAX program on my own. Not too big. I'm new to the whole matter, however I have general knowledge in programming and a good understanding of the Web workflow.

As for W3C standards, is it wrong sticking to them as if they were a platform?

Is it a good idea to code having a single platform in mind (i.e. Firefox 3 + Win7) and make it cross-browser after the initial code is finished?

In general, to what extent is browser compatibility a problem these days?

Best Answer

I would go for 2 main directions :

  • Use a framework. jQuery, mootools, prototype, or some others are great. They will handle most of quircks that you can encounter between browsers.
  • Use a testing tool that can generate a report of your code on several browsers. The basic solution is to write unit test suite (for exemple with QUnit) and then run them to browser specified with the client. You can also have a look at testSwarm or similar projet to get more automation.

And don't forget : do not try to detect browser/JS engine. Detect capabilities instead, or you are starting a endless debugging with every new browser comming on the place. Have a look at modernizr for that, this is an usefull tool.

Anyway this is a difficult goal to achieve. Those are tip that will help you with that. But the key point is debugging and testing to avoid regression on a specific plateform.

Related Topic