Skip to content

Instantly share code, notes, and snippets.

@brunoais
Created February 20, 2012 22:42
Show Gist options
  • Save brunoais/1872014 to your computer and use it in GitHub Desktop.
Save brunoais/1872014 to your computer and use it in GitHub Desktop.
file changes for the fallback of jQuery
<!--[if !IE]><script defer type="text/javascript" src="{T_JQUERY_LINK}" onerror="location.href = (location.href.indexOf('?') !== -1) ? location.href.replace(/\?/, '?altjQuery&') : (location.href.indexOf('#') === -1 ? location.href + '?altjQuery': location.href.replace(/#/, '?altjQuery#'));" ></script><![endif]-->
<!--[if IE]><script type="text/javascript" src="{T_JQUERY_LINK}" onerror="location.href = (location.href.indexOf('?') !== -1) ? location.href.replace(/\?/, '?altjQuery&') : (location.href.indexOf('#') === -1 ? location.href + '?altjQuery': location.href.replace(/#/, '?altjQuery#'));" ></script>
<!--[if lt IE 9]><script defer type="text/javascript" src="{T_TEMPLATE_PATH}/isjQueryHere.js"></script><![endif]--><![endif]-->
<script defer type="text/javascript" src="{T_ASSETS_PATH}/javascript/core.js"></script>
<script defer type="text/javascript" src="{T_TEMPLATE_PATH}/ajax.js"></script>
<!-- the rest of javascript files with the defer. As long as it is same origin all is ok -->
1st: functions.php
After the 1st if in append_sid().
if($request->is_set('altjQuery'))
{
if(is_array($params))
{
$params['altjQuery'];
}
else if(is_string($params))
{
$params .= ($is_amp? '&amp;' : '&') . 'altjQuery';
}
else
{
$params = array( 'altjQuery' => 1);
}
}
2nd add:
!$request->is_set('altjQuery')
in:
'T_JQUERY_LINK' => ($config['load_jquery_cdn'] && !empty($config['load_jquery_url'])) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery.js",
like this:
'T_JQUERY_LINK' => ($config['load_jquery_cdn'] && !empty($config['load_jquery_url']) && !$request->is_set('altjQuery') ) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery.js",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment