{"id":830,"date":"2015-12-27T17:16:22","date_gmt":"2015-12-27T17:16:22","guid":{"rendered":"http:\/\/ashton.codes\/blog\/?p=830"},"modified":"2016-11-27T18:46:53","modified_gmt":"2016-11-27T18:46:53","slug":"when-do-i-need-a-non-javascript-solution","status":"publish","type":"post","link":"https:\/\/ashton.codes\/when-do-i-need-a-non-javascript-solution\/","title":{"rendered":"When do I need a non-JavaScript solution?"},"content":{"rendered":"<p><em>The short answer to &#8220;when do I need a non-JavaScript solution&#8221;? Always. The long answer? Keep on reading&#8230;<\/em><\/p>\n<p>When I test a new feature built by another developer in my team, one of the first things I do is to turn off JavaScript and see what happens.<\/p>\n<p>Developers often act surprised at this, and look at me disdainfully for inevitably breaking their\u00a0application when I choose to access it in this way. &#8220;This is a client-side calculator! Of <em>course<\/em> it&#8217;s going to break without JavaScript!&#8221;<\/p>\n<p>Similarly, when I\u00a0sit in on meetings with developers and stakeholders discussing\u00a0what they\u00a0are hoping to build, &#8220;fallback images&#8221; and non-JavaScript solutions are often treated as a bit of an afterthought.\u00a0When I put forward the question of fallbacks, it doesn&#8217;t surprise me when the answer is a smirk and a &#8220;well, I suppose we&#8217;d better give IE8 <em>something<\/em>&#8220;.<\/p>\n<p>We&#8217;ve all become so used to modern\u00a0browsers and increasingly powerful mobile devices that the concept of a non-JavaScript solution seems an unnecessary extra effort; an additional burden on designer and developer alike. After all, the actual proportion of users who access the website without JavaScript enabled is never more than a\u00a0couple of percent.<\/p>\n<p>However, ignoring fallbacks\u00a0due to the low\u00a0percentage of\u00a0users most affected\u00a0is short-sighted and is\u00a0missing the point.<\/p>\n<h2>We&#8217;re all non-JavaScript users<\/h2>\n<p>You may have looked at the\u00a0proportion of users who access your website with JavaScript turned off through no fault of their own (e.g. corporate users of IE8) or deliberately (self-aware tech-savvies who are sick of being tracked with cookies) or who don&#8217;t even have JavaScript available in the first place (anyone using increasingly popular proxy browsers for reduced data consumption). The combined total of these users might be a tiny proportion of your overall users. Heck, it might even be zero.<\/p>\n<p>This is no excuse for ignoring your non-JavaScript implementation. Why?\u00a0To paraphrase\u00a0somebody on Twitter:<\/p>\n<blockquote><p>&#8220;Every user is a non-JavaScript user until the JavaScript loads.&#8221;<\/p><\/blockquote>\n<p>We&#8217;re not all on fiberoptic broadband connections. If you&#8217;re on a mobile phone on the train and you&#8217;re about to enter a tunnel, you&#8217;ll be stuck with whatever content arrives in the few kilobytes you managed to download before the signal cut out. Which\u00a0would you rather see: a sea of whitespace and badly formatted text\u00a0accompanied by nothing but the prospect of a seven-minute data vacuum, or the\u00a0core article text with some basic but sufficient\u00a0styling?<\/p>\n<h2>Varying degrees of non-JavaScript solutions<\/h2>\n<p>Non-interactive\u00a0features (such as <a href=\"http:\/\/responsivenews.co.uk\/post\/77054578784\/responsive-infographics-workflow-the-datapic\" target=\"_blank\">datapics<\/a>) have no interactive element and thus should get the core content, untainted by &#8220;Turn your JavaScript on!&#8221; messages. The content of the feature should be accessible and readable without jumping through hoops.\u00a0Perhaps it&#8217;s not possible for the content to look quite as polished as the JavaScript version (though if we&#8217;re disciplined about using CSS for presentation and JavaScript only for interaction, this should not be the case).<\/p>\n<p>Some features, such as quizzes, require client-side interaction to be of any real benefit to the reader. Is a non-JavaScript solution necessary, or even viable?<\/p>\n<p>When it comes to content where advanced functionality <em>is<\/em> the core content, I still expect a few things for non-JavaScript browsers:<\/p>\n<ul>\n<li>Though I&#8217;m not expecting anything particularly exciting or useful, I <em>would<\/em>\u00a0expect the page to not look broken.<\/li>\n<li>I&#8217;d expect a message something to the effect of &#8220;You must turn on JavaScript in order to view this content.&#8221;<\/li>\n<li>And I wouldn&#8217;t expect lots of unnecessary markup containing questions I can&#8217;t answer and buttons I can&#8217;t click.<\/li>\n<\/ul>\n<p>To paraphrase another anonymous tweet:<\/p>\n<blockquote><p>Use JavaScript to inject the markup your interactive application requires.<\/p><\/blockquote>\n<p>So, the answer to &#8220;when do I need a non-JavaScript solution?&#8221; is&#8230; always.<\/p>\n<h2>Other benefits of\u00a0providing a non-JavaScript solution<\/h2>\n<p>A better experience for corporate users of IE8 and for mobile users in temporary data blackspots aren&#8217;t the only advantages of implementing a defaults-first solution. Reasonable core-content experiences provide benefits in a number of other situations:<\/p>\n<ul>\n<li>Reasonable experience if another script on the page breaks your JavaScript.\n<ul>\n<li>Bugs can and do creep into live pages. Maybe the ID of the element your script hooks into has been changed, or another script on the page is re-defining jQuery at runtime, or you&#8217;ve\u00a0accidentally deleted a JavaScript dependency\u00a0from the server. Instead of the page spewing a load of JSON or unused markup\u00a0to the user, the user will be presented with a simpler\u00a0version of the same content.<\/li>\n<\/ul>\n<\/li>\n<li>Accessibility for screen readers\n<ul>\n<li>Canvas-based interactives are not\u00a0usable by screen readers. If they get a description of the <a href=\"http:\/\/chrisbashton.github.io\/Radioactive-Evolution\/Website\/game.html\" target=\"_blank\">fish game<\/a> that they could be playing in a more modern browser, disabled users at least get an understanding of what content is on the page.<\/li>\n<\/ul>\n<\/li>\n<li>Search engine optimisation\n<ul>\n<li>Canvas-based interactives are not crawlable by search-engine spiders. However, a simple description of the canvas content will give search engines an idea of what content exists on the page.<\/li>\n<\/ul>\n<\/li>\n<li>Support for harsh browser environments and future compatibility\n<ul>\n<li>Who knows what lies ahead technologically? We may one day browse the web on our toasters, pub urinals, coffee cups and Boris Bikes. We have no way of knowing what level of sophistication such browsers would support. By providing core content to all, we&#8217;re future-proofing our content as much as possible.<\/li>\n<\/ul>\n<\/li>\n<li>Clearer separation of concerns &#8211; content, presentation, interaction\n<ul>\n<li>It&#8217;s well known that HTML is for content, CSS is for presentation and JavaScript is for interaction. Keeping the three areas separate is good architecture, and supports a defaults-first development style. By delivering\u00a0our non-JavaScript solution through our markup and CSS alone, we&#8217;re fitting into this programming ideal.<\/li>\n<li>Clearer separation of concerns means more maintainable code, meaning fewer bugs, bugs which are fixed more easily, the improved ability\u00a0to work in parallel with other developers (e.g. one on presentation, one on interaction), and so on.<\/li>\n<li>Cohesive codebases and fewer bugs means hitting deadlines, and if you&#8217;re lucky,\u00a0bonuses and pay rises. As developers, we&#8217;ll have gained a stronger handle\u00a0on the advantages of keeping each area separate (the <a href=\"http:\/\/www.oodesign.com\/single-responsibility-principle.html\" target=\"_blank\">Single Responsibility Principle<\/a>), and will strive for similar ideals in the rest of our codebase, leading to better use of object orientation and the like.<\/li>\n<\/ul>\n<\/li>\n<li>Last but not least, making websites accessible is\u00a0<a href=\"https:\/\/www.gov.uk\/service-manual\/user-centred-design\/accessibility\" target=\"_blank\">the law<\/a>. Don&#8217;t risk <a href=\"http:\/\/www.karlgroves.com\/2011\/11\/15\/list-of-web-accessibility-related-litigation-and-settlements\/\" target=\"_blank\">being sued for having an inaccessible website.<\/a>\u00a0Part and parcel of this is ensuring that every solution has a non-JavaScript default.<\/li>\n<\/ul>\n<hr \/>\n<p>Continue reading: <em>Coding defaults, not fallbacks<\/em> (coming soon)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The short answer to &#8220;when do I need a non-JavaScript solution&#8221;? Always. The long answer? Keep on reading&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[],"class_list":["post-830","post","type-post","status-publish","format-standard","hentry","category-accessibility"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>When do I need a non-JavaScript solution? - Chris Ashton - Senior Developer<\/title>\n<meta name=\"description\" content=\"The short answer to &quot;when do I need a non-JavaScript solution&quot;? Always. The long answer? Keep on reading...\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ashton.codes\/when-do-i-need-a-non-javascript-solution\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"When do I need a non-JavaScript solution? - Chris Ashton - Senior Developer\" \/>\n<meta property=\"og:description\" content=\"The short answer to &quot;when do I need a non-JavaScript solution&quot;? Always. The long answer? Keep on reading...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ashton.codes\/when-do-i-need-a-non-javascript-solution\/\" \/>\n<meta property=\"og:site_name\" content=\"Chris Ashton - Senior Developer\" \/>\n<meta property=\"article:published_time\" content=\"2015-12-27T17:16:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-11-27T18:46:53+00:00\" \/>\n<meta name=\"author\" content=\"ChrisBAshton\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"ChrisBAshton\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ashton.codes\/when-do-i-need-a-non-javascript-solution\/\",\"url\":\"https:\/\/ashton.codes\/when-do-i-need-a-non-javascript-solution\/\",\"name\":\"When do I need a non-JavaScript solution? - Chris Ashton - Senior Developer\",\"isPartOf\":{\"@id\":\"https:\/\/ashton.codes\/#website\"},\"datePublished\":\"2015-12-27T17:16:22+00:00\",\"dateModified\":\"2016-11-27T18:46:53+00:00\",\"author\":{\"@id\":\"https:\/\/ashton.codes\/#\/schema\/person\/31b9570ec2884de13e1f408a803682ec\"},\"description\":\"The short answer to \\\"when do I need a non-JavaScript solution\\\"? Always. The long answer? Keep on reading...\",\"breadcrumb\":{\"@id\":\"https:\/\/ashton.codes\/when-do-i-need-a-non-javascript-solution\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ashton.codes\/when-do-i-need-a-non-javascript-solution\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ashton.codes\/when-do-i-need-a-non-javascript-solution\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ashton.codes\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"When do I need a non-JavaScript solution?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ashton.codes\/#website\",\"url\":\"https:\/\/ashton.codes\/\",\"name\":\"Chris Ashton - Senior Developer\",\"description\":\"Senior Web Developer | Software engineer | A11y evangelist\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ashton.codes\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/ashton.codes\/#\/schema\/person\/31b9570ec2884de13e1f408a803682ec\",\"name\":\"ChrisBAshton\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/ashton.codes\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/57ddfc6ac09fd027b540a44f6be841d2f5fde83d27d43b25f480c187fd172178?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/57ddfc6ac09fd027b540a44f6be841d2f5fde83d27d43b25f480c187fd172178?s=96&d=mm&r=g\",\"caption\":\"ChrisBAshton\"},\"description\":\"Senior Full Stack Developer working for GDS.\",\"url\":\"https:\/\/ashton.codes\/author\/chrisbashton\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"When do I need a non-JavaScript solution? - Chris Ashton - Senior Developer","description":"The short answer to \"when do I need a non-JavaScript solution\"? Always. The long answer? Keep on reading...","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ashton.codes\/when-do-i-need-a-non-javascript-solution\/","og_locale":"en_GB","og_type":"article","og_title":"When do I need a non-JavaScript solution? - Chris Ashton - Senior Developer","og_description":"The short answer to \"when do I need a non-JavaScript solution\"? Always. The long answer? Keep on reading...","og_url":"https:\/\/ashton.codes\/when-do-i-need-a-non-javascript-solution\/","og_site_name":"Chris Ashton - Senior Developer","article_published_time":"2015-12-27T17:16:22+00:00","article_modified_time":"2016-11-27T18:46:53+00:00","author":"ChrisBAshton","twitter_misc":{"Written by":"ChrisBAshton","Estimated reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/ashton.codes\/when-do-i-need-a-non-javascript-solution\/","url":"https:\/\/ashton.codes\/when-do-i-need-a-non-javascript-solution\/","name":"When do I need a non-JavaScript solution? - Chris Ashton - Senior Developer","isPartOf":{"@id":"https:\/\/ashton.codes\/#website"},"datePublished":"2015-12-27T17:16:22+00:00","dateModified":"2016-11-27T18:46:53+00:00","author":{"@id":"https:\/\/ashton.codes\/#\/schema\/person\/31b9570ec2884de13e1f408a803682ec"},"description":"The short answer to \"when do I need a non-JavaScript solution\"? Always. The long answer? Keep on reading...","breadcrumb":{"@id":"https:\/\/ashton.codes\/when-do-i-need-a-non-javascript-solution\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ashton.codes\/when-do-i-need-a-non-javascript-solution\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/ashton.codes\/when-do-i-need-a-non-javascript-solution\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ashton.codes\/"},{"@type":"ListItem","position":2,"name":"When do I need a non-JavaScript solution?"}]},{"@type":"WebSite","@id":"https:\/\/ashton.codes\/#website","url":"https:\/\/ashton.codes\/","name":"Chris Ashton - Senior Developer","description":"Senior Web Developer | Software engineer | A11y evangelist","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ashton.codes\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/ashton.codes\/#\/schema\/person\/31b9570ec2884de13e1f408a803682ec","name":"ChrisBAshton","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/ashton.codes\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/57ddfc6ac09fd027b540a44f6be841d2f5fde83d27d43b25f480c187fd172178?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/57ddfc6ac09fd027b540a44f6be841d2f5fde83d27d43b25f480c187fd172178?s=96&d=mm&r=g","caption":"ChrisBAshton"},"description":"Senior Full Stack Developer working for GDS.","url":"https:\/\/ashton.codes\/author\/chrisbashton\/"}]}},"_links":{"self":[{"href":"https:\/\/ashton.codes\/wp-json\/wp\/v2\/posts\/830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ashton.codes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ashton.codes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ashton.codes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ashton.codes\/wp-json\/wp\/v2\/comments?post=830"}],"version-history":[{"count":4,"href":"https:\/\/ashton.codes\/wp-json\/wp\/v2\/posts\/830\/revisions"}],"predecessor-version":[{"id":837,"href":"https:\/\/ashton.codes\/wp-json\/wp\/v2\/posts\/830\/revisions\/837"}],"wp:attachment":[{"href":"https:\/\/ashton.codes\/wp-json\/wp\/v2\/media?parent=830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ashton.codes\/wp-json\/wp\/v2\/categories?post=830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ashton.codes\/wp-json\/wp\/v2\/tags?post=830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}