4

I'm having issues with IE9 in our new website. The jQuery files aren't loading. I've tried the CDN on Google initially but have also tried the Microsoft CDN, both failing. I've seen posts about using the latest version of jQuery. I've grabbed the latest (1.6.4) and that's not helped. I understand it's the tracking protection but since this is our 'front end' site it's not like we can get browsers to add our site to their 'white list' or disable tracking protection.

Whilst hosting the files locally is the obvious next step my other concern is that google analytics code is also failing.

Is there a solution to this?

Alastair Pitts
  • 19,423
  • 9
  • 68
  • 97
lloydphillips
  • 2,775
  • 2
  • 33
  • 58
  • 1
    what's the CDN URL for your jQuery files? – Alastair Pitts Oct 25 '11 at 02:20
  • Is it possibly only failing when using a file URL scheme to test and jQuery linked to with a protocol-less path? – Marcel Oct 25 '11 at 02:25
  • @AlastairPitts tried https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js and http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.4.js. Using local file resolves the issue (as expected) but Google Analytics code isn't loading (and therefore slowing down the page load immensely). – lloydphillips Oct 25 '11 at 02:41
  • @lloydphillips: are you using the async Google Analystic code? also, your GA code should be at the bottom of the page (so it's the last thing to load) – Alastair Pitts Oct 25 '11 at 03:06
  • @AlastairPitts - yes and Analytics code is at the bottom of the page. Page still isn't displaying though. Also just realised I'm having issues with typekit js file. – lloydphillips Oct 25 '11 at 03:29

3 Answers3

15

Use the implementation of jquery as outlined in http://html5boilerplate.com/.

<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.6.4.min.js"><\/script>')</script>
jhanifen
  • 4,441
  • 7
  • 43
  • 67
  • This way if the cdn location does not load it will fall back to your local copy and everything keeps working. There are some nice videos on the html5boilerplate site talking about this implementation. – jhanifen Oct 25 '11 at 02:22
  • 3
    I'd forgotten about this! Excellent suggestion. – Alastair Pitts Oct 25 '11 at 02:27
  • It's still taking forever to 'try' to load the cdn file and aborting, by which time the other local files requiring jQuery have loaded into the browser (and thus failed when the local file loads in). – lloydphillips Oct 25 '11 at 02:52
  • Either you have a very bad internet connection or you have something very wrong with your code. Could you post your code to a gist or jsfiddle? – jhanifen Oct 25 '11 at 12:50
  • Best I can do is point you to one of the problematic pages. We're using Umbraco and given it's only a script include it's not rocket science. http://test.ecargo.co.nz/overview.aspx - remember it's an IE9 issue. All other browsers are totally fine. – lloydphillips Oct 25 '11 at 19:51
  • I noticed on our site the google code was above the end body tag so I've placed it below and this helps. It's just the typekit code that's the issue now. This isn't working outside the page - clearly has to be in the head section. Going to try conditionals. – lloydphillips Oct 25 '11 at 20:06
  • Conditionals did the job for typekit. – lloydphillips Oct 25 '11 at 20:22
1

Some variations of jhanifen's solution. By using head.js lib we can load jQuery and other libs a bit faster:

<script src="js/libs/head.load.min.js"></script>
<script>
    head.js("https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js",function() {
      window.jQuery || head.js("js/libs/jquery-1.7.1.min.js");
    });
</script>
Community
  • 1
  • 1
Anatoly Mironov
  • 7,356
  • 1
  • 26
  • 27
0

I thought it best to add my results in an answer incase someone hits this and doesn't browse the comments but best to follow the comments from the answer by @jhanifen. I had to use a local copy of jQuery, using the CDN (even on Microsoft's CDN) didn't work.

My google code wasn't sat below the end body tag, it was just above it, rectifying that resolved the issue.

Typekit, I had to use conditionals, but then that defeats the object of using Typekit, especially considering you'd think IE9 was 'a modern browser'. Crazy!

I've queried Typekit to see if they have a work around and will edit this if they come back with anything helpful.

lloydphillips
  • 2,775
  • 2
  • 33
  • 58