{"id":6996,"date":"2015-04-13T00:23:34","date_gmt":"2015-04-13T08:23:34","guid":{"rendered":"http:\/\/www.oeconomist.com\/blogs\/daniel\/?p=6996"},"modified":"2022-06-14T02:10:05","modified_gmt":"2022-06-14T09:10:05","slug":"not-following-the-script","status":"publish","type":"post","link":"https:\/\/www.oeconomist.com\/blogs\/daniel\/?p=6996","title":{"rendered":"Not Following the Script"},"content":{"rendered":"<p>I frequently run across the problem of websites whose coders silently presume that all their visitors of interest have Javascript enabled on their browsers.  Yester-day, I found this presumption affecting a page of someone whom I know (at least in passing), which prompts me to write this entry. (The person in question did not generate the code, but could suffer economic damage from its flaw.)<\/p> <p>The reason that one should <em>not<\/em> presume that Javascript is enabled on the browsers of all visitors is that Javascript is itself a recurring source of security problems.  <strong>Careful users therefore enable Javascript only for <em>sites that they trust<\/em><\/strong>; <em>very<\/em> careful users enable Javascript only for sites that they trust and even then only on an <em>as-needed<\/em> basis; and paranoid users just won't enable Javascript <em>ever<\/em>.  Now, in theory, the only visitors who might interest some site designers would be <em>careless<\/em> users, but we should look askance at those designers and at their sites.<\/p> <p>(And trusting a site shouldn't be merely a matter of trusting the competence and good will of the owner of the domain.  Unless that owner is also owner of the server that hosts the domain, one is also trusting the party from whom the site owner leases hosting.  In the past, some of my sites have been cracked by way of vulnerabilities of my host.)<\/p> <p><strong>A designer cannot infer that, if-and-when his or her site doesn't work because Javascript is not enabled, the visitor will re&auml;lize that Javascript needs to be enabled<\/strong>; many problems can produce the same symptoms.  Most of the time that sites don't work with Javascript disabled, they still don't work with it enabled.  Further, the party disabling Javascript on a browser might be different from the present user; the present user might have only vague ideas about how web pages work. (An <abbr title=\"information technology\" style=\"font-size: inherit ;\">IT<\/abbr> technician might disable Javascript for most browsers of users at some corporate site.  Some of those users, perhaps very proficient in some areas but not with <abbr title=\"information technology\" style=\"font-size: inherit ;\">IT<\/abbr>, may be tasked with finding products for the corporation.)<\/p> <p><strong>The <em>working<\/em> assumption should typically be that Javascript is <em>not<\/em> enabled<\/strong>, as this assumption will not be actively hurtful when Javascript <em>is<\/em> enabled, where&auml;s the opposite assumption will be actively hurtful when Javascript is <em>not<\/em> enabled.<\/p> <p>The <code>noscript<\/code> element of <abbr title=\"Hypertext Mark-up Language\" style=\"font-size: inherit ;\">HTML<\/abbr> contains elements or content to be used exactly and only if scripting has been <em>dis<\/em>abled.  That makes it well suited to for <em>announcements<\/em> that a page will work <em>better<\/em> if Javascript is enabled<\/p> <blockquote><code>&lt;noscript&gt;<span style=\"display: block ; margin-left: 2em ;\">&lt;p&nbsp;class=\"alert\"&gt;This page will provide greater functionality if Javascript is enabled!&lt;\/p&gt;<\/span>&lt;\/noscript&gt;<\/code><\/blockquote> <p>or not at all if it is not enabled.<\/p> <blockquote><code>&lt;noscript&gt;<span style=\"display: block ; margin-left: 2em ;\">&lt;p&nbsp;class=\"alert\"&gt;This page requires Javascript!&lt;\/p&gt;<\/span>&lt;\/noscript&gt;<\/code><\/blockquote> <p>(It is possible to put the <code>noscript<\/code> element to other uses.) So a presumption that Javascript is enabled certainly need not be <em>silent<\/em>.<\/p> <p>However, <strong>in many cases, the effect got with Javascript isn't worth badgering the visitor to enable Javascript, and the page could be coded<\/strong> (with or without use of the <code>noscript<\/code> element) <strong>so that it still worked well without Javascript<\/strong>.  <strong>In other cases, the same effects or very nearly the same effects could be got without any use of Javascript<\/strong>; a great deal that is done with Javascript could instead be done with <abbr title=\"Cascading Style Sheets\" style=\"font-size: inherit ;\">CSS<\/abbr>.<\/p>","protected":false},"excerpt":{"rendered":"I frequently run across the problem of websites whose coders silently presume that all their visitors of interest have Javascript enabled on their browsers. Yester-day, I found this presumption affecting a page of someone whom I know (at least in passing), which prompts me to write this entry. (The person in question did not generate [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[6,117,69,4],"tags":[1261,249,1260,1263,146,1262,1259,1264],"class_list":["post-6996","post","type-post","status-publish","format-standard","hentry","category-commentary","category-communication","category-information-technology","category-public","tag-cascading-style-sheets","tag-coding","tag-css","tag-ecmascript","tag-html","tag-hypertext-mark-up-language","tag-javascript","tag-webpages"],"_links":{"self":[{"href":"https:\/\/www.oeconomist.com\/blogs\/daniel\/index.php?rest_route=\/wp\/v2\/posts\/6996","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oeconomist.com\/blogs\/daniel\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oeconomist.com\/blogs\/daniel\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oeconomist.com\/blogs\/daniel\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oeconomist.com\/blogs\/daniel\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6996"}],"version-history":[{"count":1,"href":"https:\/\/www.oeconomist.com\/blogs\/daniel\/index.php?rest_route=\/wp\/v2\/posts\/6996\/revisions"}],"predecessor-version":[{"id":11980,"href":"https:\/\/www.oeconomist.com\/blogs\/daniel\/index.php?rest_route=\/wp\/v2\/posts\/6996\/revisions\/11980"}],"wp:attachment":[{"href":"https:\/\/www.oeconomist.com\/blogs\/daniel\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6996"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oeconomist.com\/blogs\/daniel\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6996"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oeconomist.com\/blogs\/daniel\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6996"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}