Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Include jQuery based-on user's IE version.
* 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="//' . $version . '/jquery.min.js"></script>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.