Skip to content

Instantly share code, notes, and snippets.

@J2TEAM
Created April 19, 2016 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save J2TEAM/451a514f232f68104bd4c725a1aef408 to your computer and use it in GitHub Desktop.
Save J2TEAM/451a514f232f68104bd4c725a1aef408 to your computer and use it in GitHub Desktop.
Include jQuery based-on user's IE version.
<?php
/**
* jQuery 2.x has the same API as jQuery 1.x, but does not support Internet Explorer 6, 7, or 8.
* All the notes in the jQuery 1.9 Upgrade Guide apply here as well. Since IE 8 is still relatively common,
* we recommend using the 1.x version unless you are certain no IE 6/7/8 users are visiting the site.
*/
function include_jquery() {
if(preg_match('/(?i)msie [6-8]/', $_SERVER['HTTP_USER_AGENT'])) {
// if IE<=8
$version = '1.12.2';
} else {
// if IE>8
$version = '2.2.2';
}
echo '<script src="//ajax.googleapis.com/ajax/libs/jquery/' . $version . '/jquery.min.js"></script>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment