All in the <head>

– Ponderings & code by Drew McLellan –

– Live from The Internets since 2003 –

About

Version Targeting and JavaScript Libraries

24 January 2008

The discussion about version targeting continues. In Version Two Eric writes:

The handling of JavaScript libraries in a world where the pages calling the libraries will determine how the JS is interpreted – that’s definitely something I hadn’t considered. As I understand it, the problem case is one where a JS library that uses (say) IE9 features is loaded into a page that triggers the IE7 engine. The library would need to preserve backward compatibility with all the IE versions that could be used.

But isn’t that already the case? Every library whose source I’ve studied has all kinds of detection, whether it’s feature or browser detection, in order to work with multiple browsers. I would think that under version targeting, the same thing would be necessary: you do feature detection and work accordingly. Again, it’s entirely possible I missed something there, so feel free to let me know what it was.

The issue with JavaScript libraries (and embedded widgets) is an important one. Eric is right that libraries have to already cope with multiple browser versions, of course. The difference is that, over time, those old versions disappear. A library or widget developed today doesn’t need to really take IE5 or even IE5.5 into account because those browsers have gone away to an extent that it’s acceptable to not serve them your page’s behaviour layer (a la Yahoo’s Graded Browser Support).

The difference with version targeting is that IE7 ‘mode’ is never going to go away. Fast-forward to 2012 when the current version of IE is IE11, but there’s still a good proportion of IE10 in the marketplace. A JavaScript library has to include conditions not just around any quirks in IE10 and IE11, but also all those quirks from IE7.

If there happen to be any differences in the way IE7 mode is implemented, the library may even need to cope with IE10’s IE7 mode and IE11’s IE7 mode. If the library does anything with CSS (for example a drag and drop script) variations in CSS rendering across all those implementations has to be taken into account too.

Developing for the current browser plus the previous version is inconvenient but readily achievable. Developing for the current version, the previous version and a version 4 years old is not only a nightmare, but also limits the functionality you can use and slows the progress of the web.

With version targeting, IE7 will never go away. Just as browsers are born, they must also die and make way for the next generation.

- Drew McLellan

Comments

  1. § Bryan Helmkamp:

    Agreed. But (fortunately) there’s an important point you missed…

    A library could be written to just target IE11 and IE10 and simply proclaim it cannot be used in IE7 targeted pages.

    Since developers using a modern JS library are likely to prefer supporting the most modern rendering engines available, this may not be so big of an issue.

  2. § Drew:

    That might work for libraries, Bryan, but consider also things like embedded widgets and ‘badges’ (like a Flickr badge or similar). It’s in a company’s interests to get their service promoted through such things in as many places as possible – and to do so in a slick way, not in a way that looks like a crappy badge written 4 years ago.

  3. § Eric Meyer:

    I think I understand, although it seems like feature detection as opposed to browser detection would alleviate much of this issue, would it not? (Maybe not, which is why I ask.)

    Also, I’ve noticed that a number of supporters of the general idea are JS library and AJAX developer types—Alex Russell, for one example, though there are others. What causes that difference in opinion, do you think? I’d like to know because understanding the difference might help illuminate the whole topic from a different angle.

  4. § Jon:

    Under current proposal IE10 and IE11 (or whatever) would default to IE7 but the amount of people actually using IE7 will be immeasurably small if not in fact none. Perhaps the default rendering engine could be updated but just on a much slower timetable. Indeed this highlights a problem with version targeting; Is it truly sustainable?

  5. § Sebi:

    Good point in the argument on the new targeting mechanism proposed by Microsoft. Displaying old pages only by means of a specific mode in newer browsers seems ridiculous to me. The same issue accured in case of Word, and this problem still hasn’t been resolved properly. Hopefully IE9 will involve a more reasonable rendering mechanism.

  6. § Mike:

    I think the biggest problem here was hinted at, but not spelled out entirely: there is a significant possibility that IE10 etc will support JS3, but still allow the IE7-compatible CSS mode, so will support JS features that make no sense to the available DOM. Browser sniffing will be of little use, which is just one more reason to oppose this irresponsible idea from Microsoft.

Photographs

Work With Me

edgeofmyseat.com logo

At edgeofmyseat.com we build custom content management systems, ecommerce solutions and develop web apps.

Follow me

Affiliation

  • Web Standards Project
  • Britpack
  • 24 ways

Perch - a really little cms

About Drew McLellan

Photo of Drew McLellan

Drew McLellan (@drewm) has been hacking on the web since around 1996 following an unfortunate incident with a margarine tub. Since then he’s spread himself between both front- and back-end development projects, and now is Director and Senior Web Developer at edgeofmyseat.com in Maidenhead, UK (GEO: 51.5217, -0.7177). Prior to this, Drew was a Web Developer for Yahoo!, and before that primarily worked as a technical lead within design and branding agencies for clients such as Nissan, Goodyear Dunlop, Siemens/Bosch, Cadburys, ICI Dulux and Virgin.net. Somewhere along the way, Drew managed to get himself embroiled with Dreamweaver and was made an early Macromedia Evangelist for that product. This lead to book deals, public appearances, fame, glory, and his eventual downfall.

Picking himself up again, Drew is now a strong advocate for best practises, and stood as Group Lead for The Web Standards Project 2006-08. He has had articles published by A List Apart, Adobe, and O’Reilly Media’s XML.com, mostly due to mistaken identity. Drew is a proponent of the lower-case semantic web, and is currently expending energies in the direction of the microformats movement, with particular interests in making parsers an off-the-shelf commodity and developing simple UI conventions. He writes here at all in the head and, with a little help from his friends, at 24 ways.