Working on a variety of servers, I encountered a common issue where some externally loaded resources would throw an error in Chrome: "Uncaught SyntaxError: Unexpected token ILLEGAL".
While jQuery from the googleapis CDN loads without any problems, attempting to load a JavaScript font file from fonts.com and the basic Google Analytics code both result in errors.
Below is the code snippet causing the issue (you can also view it on this fiddle):
<html>
<head>
<title>fonttest</title>
<script type="text/javascript" src="http://fast.fonts.com/jsapi/dd7c6b7d-1ecb-4ef4-bf65-c4759f97cbe3.js"></script>
<script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script>
</head>
<body>
<h2>This is a test of the emergency broadcast system. This is only a test. If this had been an actual emergency, the tones you just heard would have been followed by official news or instructions.</h2>
</body>
</html>
The headers for these files are specified as text/javascript
.
Upon inspecting the resource in the Web Inspector's Resources tab, non-Roman characters were displayed instead of the expected code, suggesting a possible encoding issue. I attempted setting the charset to both utf-8
and iso-8859-1
in the document head using meta charset
, but unfortunately, neither solution resolved the problem.