title: The #ViewSource Affordance
url: https://htmx.org/essays/right-click-view-source/
hash_url: 2782723c95c98a22087e9954b07a8fba

<blockquote>
<p>Not for nothing, Hypercard presaged the web’s critical “#ViewSource” affordance, which allowed people to copy,
modify, customize and improve on the things that they found delightful or useful.  This affordance was later adapted 
by other human-centered projects like #Scratch, and is a powerful tonic against #enshittification.</p>
<p>--<a rel="noopener" target="_blank" href="https://twitter.com/doctorow/status/1701934612686196872">Cory Doctorow @pluralistic@mamot.fr</a></p>
</blockquote>
<h2 id="open-culture-the-web"><a class="zola-anchor" href="#open-culture-the-web" aria-label="Anchor link for: open-culture-the-web">#</a>Open Culture &amp; The Web</h2>
<p>When people talk about open source software, that conversation is often dominated by
<a rel="noopener" target="_blank" href="https://www.gnu.org/philosophy/free-sw.html">the Free Software Foundation’s notion of free software</a>:</p>
<blockquote>
<p>“Free software” means software that respects users’ freedom and community. Roughly, it means that the users have the 
freedom to run, copy, distribute, study, change and improve the software.“</p>
</blockquote>
<p>This definition of free software has been a useful one and, through advocating for it, the FSF has gifted the world a 
lot of wonderful open source software.</p>
<p>Web applications, however, have always been an uncomfortable fit for this definition of free.  This is mainly
for technical reasons: web applications involve a web browser interacting with a web server that is, typically, running
on a remote system.</p>
<p>At a fundamental level, the REST-ful architecture of the web was built around <em>hypermedia representations</em> of remote
resources:  browsers deal only with hypermedia representations provided by the server and, thus, have no visibility into
the actual source of the code executing on the server side.</p>
<p>Now, the web has certainly <em>leveraged</em> free and open source software in its growth: browsers are typically (at least mostly)
open source, server software is often open source, and so on.  And there are, of course, open source web applications
that users may run for things like forums and so forth.</p>
<p>However, from the standpoint of typical web application users, web applications are not free in the FSF sense of that
term: the users are unable to see and modify the source of the server code that is being executed as they interact with
the application via the browser.</p>
<h3 id="right-click-view-source-as-culture"><a class="zola-anchor" href="#right-click-view-source-as-culture" aria-label="Anchor link for: right-click-view-source-as-culture">#</a>Right-Click-View-Source As Culture</h3>
<p>Despite the fact that the web has a somewhat uncomfortable relationship with the notion of free software, the early web 
none-the-less had a radically open <em>developer culture</em>. </p>
<p>In fact, in some important and practical ways, the early web had a <em>more</em> open developer culture than what was achieved 
by the free software movement.</p>
<p>The <a rel="noopener" target="_blank" href="https://en.wikipedia.org/wiki/View-source_URI_scheme">#ViewSource</a> affordance available in browsers allowed people 
to understand and “own”, at least in an informal way, the web in a way that even most FSF-conforming applications could 
not: you had direct access to the “source”, or at least <em>part</em> of the source, of the application available from 
<em>within</em> the application itself.</p>
<p>You could copy-and-paste (or save) the “source” (HTML, JavaScript &amp; CSS) and start modifying it, without a complicated
build tool chain or, indeed, without any tool chain at all.</p>
<p>This radical openness of the web allowed many people, often not formally trained computer programmers, to learn how to 
create web pages and applications in an ad hoc and informal way.</p>
<p>In strict free software terms, this was, of course, a compromise: as a user of a web application, you had no visibility 
into how a server was constructing a given hypermedia response.</p>
<p>But you could see <em>what</em> the server was responding with: you could download and tweak it, poke and prod at it.  You could,
if you were an advanced user, use browser tools to modify the application in place.</p>
<p>And, most importantly, you could <em>learn from it</em>, even if you couldn’t see how the HTML was being produced.</p>
<p>This radical openness of the client and network protocol, and the culture it produced, was a big part of the success
of the early web.</p>
<h2 id="digital-enclosure-vs-technical-enclosure"><a class="zola-anchor" href="#digital-enclosure-vs-technical-enclosure" aria-label="Anchor link for: digital-enclosure-vs-technical-enclosure">#</a>Digital Enclosure vs. Technical Enclosure</h2>
<p>The <a rel="noopener" target="_blank" href="https://en.wikipedia.org/wiki/Enclosure">Enclosure Movement</a> was a period in English history when what were 
previously <a rel="noopener" target="_blank" href="https://en.wikipedia.org/wiki/Commons">commons</a> were privatized.</p>
<p>This was a traumatic event in English history, as evidenced by this poem by an 18th century anon:</p>
<blockquote>
<p>The law locks up the man or woman</p>
<p>Who steals the goose from off the common,</p>
<p>But lets the greater felon loose</p>
<p>Who steals the common from the goose.</p>
<p>–18th century anon</p>
</blockquote>
<p>In the last decade, the web has gone through a period of “Digital Enclosure”, where <a rel="noopener" target="_blank" href="https://en.wikipedia.org/wiki/Closed_platform">“Walled Gardens”</a>,
such as Facebook &amp; Twitter, have replaced the earlier, more open and more chaotic blogs and internet forums.</p>
<h3 id="technical-enclosure"><a class="zola-anchor" href="#technical-enclosure" aria-label="Anchor link for: technical-enclosure">#</a>Technical Enclosure</h3>
<p>Many (most?) web developers have decried this trend.</p>
<p>However, despite recognizing the danger of an increasingly closed internet, many web developers don’t consider their own
technical decisions and how those decisions can also contribute to the disappearance of web’s <em>culture</em> of openness.</p>
<p>Inadvertently (for the most part) technical trends and decisions in web development in the last two decades have lead
to what we term a “Technical Enclosure” of the web, a processes whereby technical decisions chip away at the #ViewSource
affordance that Cory Doctrow discusses in the opening quote of this article, an affordance that existed as a commons
for early web developers.</p>
<p>To see a stark example of the decline of the <a rel="noopener" target="_blank" href="https://en.wikipedia.org/wiki/View-source_URI_scheme">#ViewSource</a> affordance
in web development and Technical Enclosure in action, we can look at what is perhaps the most popular web page on the 
internet, <a rel="noopener" target="_blank" href="https://google.com">The Google Homepage</a>.</p>
<p>Here is the nearly complete source of that page from the year 2000, taken from 
<a rel="noopener" target="_blank" href="http://web.archive.org/web/20000229040250/http://www.google.com/">the wayback machine</a>:</p>
<h3 id="google-in-2000"><a class="zola-anchor" href="#google-in-2000" aria-label="Anchor link for: google-in-2000">#</a>Google in 2000</h3>
<img src="https://htmx.org/img/google-2000.png" alt="Google Source Code in 2000">
<p>In contrast, here is a random snapshot of roughly 1/100th of the current source code for the website:</p>
<h3 id="google-in-2023"><a class="zola-anchor" href="#google-in-2023" aria-label="Anchor link for: google-in-2023">#</a>Google in 2023</h3>
<img src="https://htmx.org/img/google-2023.png" alt="Google Source Code in 2023">
<p>These two screenshots dramatically demonstrate the decline in the effectiveness of the <a rel="noopener" target="_blank" href="https://en.wikipedia.org/wiki/View-source_URI_scheme">#ViewSource</a> affordance over time:
yes, you can still right-click the page and view its underlying source, but making sense of the latter code would be
challenging for even the most seasoned web developer.</p>
<p>A new web developer would have almost no chance of deriving any value from doing so.</p>
<p>Now, this is not to criticize the google engineer’s technical decisions that lead to this situation <em>as technical 
decisions</em>: obviously, despite similar appearances, the google homepage of 2023 is far more sophisticated than the one 
available in 2000.</p>
<p>The 2023 google homepage is going to be a lot more complicated than the 2000 page and, given the zeitgeist, it is going to 
involve a lot of JavaScript.</p>
<p>However, this is to point out that something deeply important about the early web has been lost, almost certainly 
unintentionally, along the way: the ability to view the source of the page, make sense of what it is doing and, most 
importantly, to learn from it.</p>
<h2 id="right-click-view-source-extremism"><a class="zola-anchor" href="#right-click-view-source-extremism" aria-label="Anchor link for: right-click-view-source-extremism">#</a>Right-Click-View-Source Extremism</h2>
<p>Both <a href="https://htmx.org/">htmx</a> and <a rel="noopener" target="_blank" href="https://hyperscript.org">hyperscript</a> adhere to the <a href="https://htmx.org/essays/locality-of-behaviour/">Locality of Behavior</a>
design principle.</p>
<p>This principle states that:</p>
<blockquote>
<p>The behaviour of a unit of code should be as obvious as possible by looking only at that unit of code</p>
</blockquote>
<p>The main technical advantage of Locality of Behavior is ease of maintenance, as outlined in the essay above.</p>
<p>However, there is an important cultural benefit to the Locality of Behavior of htmx and hyperscript as well: <strong>it restores
the power of the <a rel="noopener" target="_blank" href="https://en.wikipedia.org/wiki/View-source_URI_scheme">#ViewSource</a> affordance on the web</strong>.</p>
<p>Consider <a rel="noopener" target="_blank" href="https://arhamjain.com/hyperwordle/">Hyperwordle</a>, a hyperscript-based clone of the popular 
<a rel="noopener" target="_blank" href="https://www.nytimes.com/games/wordle/index.html">Wordle</a> game, now owned by the New York Times.</p>
<p>You can visit Hyperwordle, right click and view the source of it, and you will be presented with some HTML and hyperscript,
all of which is, with a bit of effort, understandable.</p>
<p>The  <a rel="noopener" target="_blank" href="https://en.wikipedia.org/wiki/View-source_URI_scheme">#ViewSource</a> affordance is effective in this case.</p>
<p>Contrast this with the view-source experience of the Wordle implementation at the New York Times.</p>
<p>Now, this is of course a bit unfair: the NYTimes version has a lot more functionality and is heavily optimized. Hyperwordle
is a proof of concept and not being hammered by millions of users every day.</p>
<p>Despite that qualification, Hyperwordle demonstrates a potential future for the web, a future where a culture of openness,
of <a rel="noopener" target="_blank" href="https://en.wikipedia.org/wiki/View-source_URI_scheme">#ViewSource</a> politeness, is once again a touchstone of the
culture of the web.</p>

<p>Engineers who care about the open culture of the web should recognize that the threats to that culture come not only from
Digital Enclosure by large, private companies of the most important pieces of the web.</p>
<p>They should also recognize the risks of Technical Enclosure, and the <em>non-technical</em> value of the 
<a rel="noopener" target="_blank" href="https://en.wikipedia.org/wiki/View-source_URI_scheme">#ViewSource</a> affordance in perpetuating the open culture of
web development.  They should start thinking about making this affordance a priority in their technical decisions.  As
with all priorities, this may involve trading off against other technical and even functional priorities during 
application development.</p>
<p>But if we don’t stand up for <a rel="noopener" target="_blank" href="https://en.wikipedia.org/wiki/View-source_URI_scheme">#ViewSource</a>, no one else will.</p>

<img src="https://htmx.org/img/memes/viewsource.png" alt="Right Click View Source Guy">
