{"id":581,"date":"2013-02-01T15:55:19","date_gmt":"2013-02-01T22:55:19","guid":{"rendered":"http:\/\/10kdev.ivystreetinc.com\/?p=581"},"modified":"2013-02-01T15:58:20","modified_gmt":"2013-02-01T22:58:20","slug":"ie8-not-loading-backbonejslesscss-application","status":"publish","type":"post","link":"http:\/\/10kdev.net\/?p=581","title":{"rendered":"IE8 Not Loading BackboneJS\/LessCSS Application"},"content":{"rendered":"<p>Kinda funny &#8212; we have a new application and none of us were testing it in IE8! \u00a0Sound familiar? \ud83d\ude42<\/p>\n<p>The application wouldn&#8217;t load at all, not at all, in IE8. Debugging was tedious with the IE8 debug tool.<\/p>\n<p>Our specs are pretty up to date but IE8 is still on the table for our customers. \u00a0The headless testing isn&#8217;t set up with any IE instances to cover this either. The UI piece is Backbone, Require, Underscore, JQuery, and Less. \u00a0All tried javascript technologies.<\/p>\n<p><strong>Fix the Tests<\/strong><br \/>\nFirst, I noticed none of the QUnits ran in IE8. \u00a0So tracing it back, I noticed there was a library someone had put into the applications Require configuration, but not in the test config &#8212; and that did the trick. \u00a0For whatever reason it worked in the other browsers.<\/p>\n<p><strong>Fix the Application<\/strong><br \/>\nNext, the application wasn&#8217;t loading at all in IE8 at runtime. \u00a0I had to do three more things to get it working:<\/p>\n<p>1. \u00a0Move a console.log patch to load with the application &#8212; IE8 can&#8217;t do console.log unless its debugging and developers were putting them all over in the code. This technique is well documented on StackOverflow and other sites. Looks like this:<\/p>\n<pre class=\"brush: jscript; light: true; title: ; notranslate\" title=\"\">\r\n\/\/mock_log_console.js\r\nif (typeof ( console ) !== 'undefined' &amp;&amp; console != null) {\r\n\r\n} else {\r\n    console = {\r\n       log:function () {\r\n           \/\/alert(&quot;log&quot;); \/\/if you want, I usually do not\r\n       },\r\n       warn:function () {\r\n       },\r\n       error:function () {\r\n    }\r\n  }\r\n}\r\n<\/pre>\n<p>Make sure this script is called before everything else in your index.html or whatever:<\/p>\n<pre class=\"brush: xml; light: true; title: ; notranslate\" title=\"\">\r\n&lt;script type=&quot;text\/javascript&quot; src=&quot;mock_log_console.js&quot;&gt;&lt;\/script&gt;<\/pre>\n<p>2. Change the doctype. We had<\/p>\n<pre class=\"brush: xml; light: true; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n<\/pre>\n<p>but it was causing IE8 not to load the page, so I put in this, that seemed to solve it:<\/p>\n<pre class=\"brush: xml; light: true; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html PUBLIC &quot;-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN&quot;\r\n &quot;http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd&quot;&gt;\r\n<\/pre>\n<p>3. IE8 was hating it when we set the type as follows:<\/p>\n<pre class=\"brush: xml; light: true; title: ; notranslate\" title=\"\">\r\n\r\n&lt;script type=&quot;application\/javascript&quot;&gt;&lt;\/script&gt;\r\n\r\n<\/pre>\n<p>So &#8220;type=&#8217;application\/javascript&#8217; &#8220;had to come out &#8212; nothing set now at all.<\/p>\n<p><strong>Closing<\/strong><br \/>\nDebugging and fixing consisted of:<\/p>\n<ol>\n<li>Making sure the right libraries got loaded.<\/li>\n<li>Checking the syntax compliancy of the code to IE8 specs &#8212; for instnace, console.log(), DOCTYPE and acceptable script properties.<\/li>\n<li>A lot of elbow grease.<\/li>\n<\/ol>\n<p>On other environments, Less is already compiled &#8212; but continues to be a problem loading slow and needed refreshes for IE8 when resolving at runtime. \u00a0We decided there was nothing we could do to solve this, except point at optimized CSS files at the right time. \u00a0There are ways of compiling everything but what you are woking on too.<\/p>\n<p>Again, elbow grease. \u00a0Who ever said this shit gets any easier?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kinda funny &#8212; we have a new application and none of us were testing it in IE8! \u00a0Sound familiar? \ud83d\ude42 The application wouldn&#8217;t load at all, not at all, in IE8. Debugging was tedious with the IE8 debug tool. Our specs are pretty up to date but IE8 is still on the table for our [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/581"}],"collection":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=581"}],"version-history":[{"count":25,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/581\/revisions"}],"predecessor-version":[{"id":607,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/581\/revisions\/607"}],"wp:attachment":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=581"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}