javascripthtmlinternet-explorerbrowserlabjs

IE8 Unbelievable Problem with inline LAB.JS script


I have been trying to make my website performs well. One way that may achieve this is by including a loader like LAB.js script inline within my HTML, and then load my scripts in parallel in the next line.

So, inside LAB.js library that contains a bunch of codes, there is this particular line of code{var c=/^\w+\:\/\//,d;if(typeof a!=q). When I put that piece of code inline inside the script tag of my HTML, it works well both In mozilla and chrome..but then..it fails in this browser called internet explorer 8 built by this great software company called "microsoft".

take a look at the part where there is "\/\//". Those last two characters "//" are parsed without any problem in both mozilla and chrome. However in IE, the last two characters are parsed as comment operators, therefore, any codes after those last two lines are rendered as comments (useless). This is really unbelievable. In IE, the rest of the codes after those two characters are literally useless and green colored (as in comment) Have anyone seen this issue happening before? Pls help. thanks.

In Mozilla and chrome: (last two characters)"//",d;if(typeof a!=q)

In IE: //,d;if(typeof a!=q)


Solution

  • You could surround your regex with (?:...):

     c=/(?:^\w+\:\/\/)/,d;if(typeof a!=q)