jQuery Versions & NuGet

Background:

jQuery 2.x was released that recently dropped support for IE8.  If you want to support IE8, you need to be aware of the version you are on.

http://blog.jquery.com/2013/04/18/jquery-2-0-released/

 “jQuery 2.0 is intended for the modern web; we’ve got jQuery 1.x to handle older browsers and fully expect to support it for several more years. If you want, you can serve 2.0 to newer browsers and 1.9 to older ones using our conditional comment trick, but that is not required. The simplest way to support older browsers is to use jQuery 1.x on your site, since it works for all browsers.”

How do I rollback to jQuery version 1.x?

Rolling back to jQuery version 1.x is a simple process using the Package Manager Console and the Package Manager UI.

  1. Open the Package Manager Console (Tools >> Library Package Manager >> Package Manager Console)
  2. Run the following commands
    1. Uninstall-Package jquery –Force
    2. install-package jquery -version 1.9.0
    3. **Update the packages.config file to set the allowdVersions.  This will allow any versions from 1.9.0 up to, but not including 2.0.
      1. <package id=”jQuery” version=”1.9.0″ targetFramework=”net40″ allowedVersions=”[1.9.0,2)” />
      2. Right Click on References >> Manage NuGet Packages
      3. You should see an update for latest version jQuery less than 2.0. (jQuery 1.10.1)
      4. You are good to go!

**Notice the inclusive vs. exclusive values.  The functionality requires NuGet version 2.5+

[ = inclusive
( = exclusive

http://docs.nuget.org/docs/reference/Versioning

I haven’t updated my jQuery version, how do I stay on version 1.x?

NuGet has made a very simple configuration to control your NuGet package versions.    The functionality requires NuGet version 2.5+.

  1. **Update the packages.config file to set the allowdVersions.  This will allow any versions from 1.9.0 up to, but not including 2.0.
    1. <package id=”jQuery” version=”1.9.0″ targetFramework=”net40″ allowedVersions=”[1.9.0,2)” />
    2. Right Click on References >> Manage NuGet Packages
    3. You should see an update for latest version jQuery less than 2.0. (jQuery 1.10.1)
    4. You are good to go!

**Notice the inclusive vs. exclusive values.  The functionality requires NuGet version 2.5+

[ = inclusive
( = exclusive

http://docs.nuget.org/docs/reference/Versioning

Nate Bunton

Nate Bunton is a Lead Software Engineer at Meta Payment Systems. He has over 10 years developing software and leading teams. He works with the Microsoft technology stack focusing in ASP.NET, MVC, HTML, JavaScript, CSS and Web Security. Nate also focuses on Application Lifecycle Management (ALM) engaging his teams with key stakeholders using a variety of agile principals. At Meta Payment Systems, Nate has been a leader in driving technology in the enterprise from new Web Technology to Service Oriented Architecture using WCF and NServiceBus. Nate’s greatest passion is for User Experience, Web Technology and Engaging Teams. He is driven by his desire for continuous learning & improvement.

Posted in Web Development Tagged with: , , , , ,