Skip to content

Instantly share code, notes, and snippets.

@emanuele45
Created December 10, 2012 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emanuele45/b75ed06e0df2711c4c6f to your computer and use it in GitHub Desktop.
Save emanuele45/b75ed06e0df2711c4c6f to your computer and use it in GitHub Desktop.
jquery uglyfication...
else
{
// load JQuery if needed
if (!$do_defered && isset($context['javascript_files']['jquery']))
echo '
<script type="text/javascript" src="', $context['javascript_files']['jquery']['filename'], '" id="jquery"', !empty($context['javascript_files']['jquery']['options']['async']) ? ' async="async"' : '', '></script>';
// and the fallback...if needed
if (!$do_defered && isset($context['javascript_files']['jquery']) && (!isset($modSettings['jquery_source']) || $modSettings['jquery_source'] === 'auto'))
echo '
<script type="text/javascript"><!-- // --><![CDATA[
window.jQuery || document.write(\'<script src="' . $settings['default_theme_url'] . '/scripts/jquery-1.7.2.min.js"><\/script>\');
// ]]></script>';
// While we have Javascript files to place in the template
foreach ($context['javascript_files'] as $id => $js_file)
{
if ($id === 'jquery')
continue;
if ((!$do_defered && empty($js_file['options']['defer'])) || ($do_defered && !empty($js_file['options']['defer'])))
echo '
<script type="text/javascript" src="', $js_file['filename'], '" id="', $id, '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>';
// If we are loading JQuery and we are set to 'auto' load, put in our remote success or load local check
if ($id === 'jquery' && (!isset($modSettings['jquery_source']) || $modSettings['jquery_source'] === 'auto'))
$loadjquery = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment