Skip to main content
Topic: [bug] - jQuery fallback failing if cdn not available (Read 4454 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[bug] - jQuery fallback failing if cdn not available

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?
Bugs creator.
Features destroyer.
Template killer.

Re: [bug] - jQuery fallback failing if cdn not available

Reply #1

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

Re: [bug] - jQuery fallback failing if cdn not available

Reply #2

It was about 1:00 AM when I wrote the message.

 emanuele wasn't exactly "awake"... :P
Bugs creator.
Features destroyer.
Template killer.