SharePoint 2010 and jQuery 2.x

Recently, I was working with a coworker who had created a javascript dashboard using jQuery and KnockoutJS in SharePoint.  The dashboard had worked perfectly for him, but when I viewed the site none of the data would render.  While we were testing the site we noticed that my browser was running in Browser Mode IE10 with Document Standard IE 7 Standard, but his was running Browser Mode IE 10 with Document Mode: Standards.  Having battled with SharePoint 2010 using an HTML5 Masterpage I began looking for the Meta tag on the page which should define the appropriate browser mode and noticed he had removed it.  I had him add the tag back to the masterpage (from my experience removing the browser mode tag in SP2010 causes all kinds of issues when editing pages, list items, etc) but still found the dashboard was not functioning properly.

When we looked at the jQuery include I noticed he was using the latest version from the Microsoft CDN, which happens to be version 2.x.  Because I had another site running with jQuery and Knockout I had him revert his version of jQuery to 1.10.x and we found this was working.

The cause of the issue is detailed in the jQuery documentation for 2.x:
jQuery 2.x has the same API as jQuery 1.x, but does not support Internet Explorer 6, 7, or 8. (source)
The reason this is relevant is because SharePoint masterpages include:
<meta http-equiv=”X-UA-Compatible”content=”IE=8″/>
Which forces IE browsers to effectively run in an IE 8 mode.

Therefore, if you are a SharePoint 2010 developer and are attempting to use jQuery, make sure you are using 1.x versions

Advertisements

One comment

  1. Nice catch, David.

    I wouldn’t recommend using jQuery 2.x in any SharePoint installations for a good, long while. It’s not just the next version of jQuery, it’s a departure from jQuery’s underpinnings on several levels. Because it removes support for older versions of Internet Explorer and most SharePoint shops have a strong IE install base, it’s just not a good idea unless you understand exactly what browsers you’re dealing with.

    There are other reasons, but that’ probably good enough for most of us.

    M.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s