ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: emanuele on December 10, 2012, 06:50:30 pm

Title: [bug] - jQuery fallback failing if cdn not available
Post by: emanuele on December 10, 2012, 06:50:30 pm
Subject says it all. :P

If google cdn is not available the entire jQuery becomes unavilable because the fallback code is added at the bottom of the page (way too late to properly initialise all the jQ plugins we are using.

At the moment the only solution I found is this ugly code:
https://gist.github.com/b75ed06e0df2711c4c6f
any idea?
Title: Re: [bug] - jQuery fallback failing if cdn not available
Post by: Spuds on December 11, 2012, 12:14:08 am
Could we just not use LoadJavascriptFile for jquery at all and then consolidate its options at the start of template_javascript since if its being loaded it needs to go first anyway.

So we then remove all the jquery conditionals in Load.php, Combine.php, and in Subs.php and anywhere else and then just do something like this at the start of template_javascript?

Code: [Select]
	// First up, load jquery
if (isset($modSettings['jquery_source']) && !$do_defered)
{
switch ($modSettings['jquery_source'])
{
case 'cdn':
echo '
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" id="jquery"></script>';
break;
case 'local':
echo '
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/jquery-1.7.2.min.js" id="jquery"></script>';
break;
case 'auto':
echo '
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" id="jquery"></script>
<script type="text/javascript"><!-- // --><![CDATA[
window.jQuery || document.write(\'<script src="', $settings['default_theme_url'], '/scripts/jquery-1.7.2.min.js"><\/script>\');
// ]]></script>';
break;
}
}

Of course its late here so who knows what I am thinking :P
Title: Re: [bug] - jQuery fallback failing if cdn not available
Post by: emanuele on December 11, 2012, 05:39:52 am
It was about 1:00 AM when I wrote the message.

/me wasn't exactly "awake"... :P