A place to cache linked articles (think custom and personal wayback machine)
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

index.html 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <!doctype html><!-- This is a valid HTML5 document. -->
  2. <!-- Screen readers, SEO, extensions and so on. -->
  3. <html lang="fr">
  4. <!-- Has to be within the first 1024 bytes, hence before the <title>
  5. See: https://www.w3.org/TR/2012/CR-html5-20121217/document-metadata.html#charset -->
  6. <meta charset="utf-8">
  7. <!-- Why no `X-UA-Compatible` meta: https://stackoverflow.com/a/6771584 -->
  8. <!-- The viewport meta is quite crowded and we are responsible for that.
  9. See: https://codepen.io/tigt/post/meta-viewport-for-2015 -->
  10. <meta name="viewport" content="width=device-width,initial-scale=1">
  11. <!-- Required to make a valid HTML5 document. -->
  12. <title>Honesty is the best policy (archive) — David Larlet</title>
  13. <meta name="description" content="Publication mise en cache pour en conserver une trace.">
  14. <!-- That good ol' feed, subscribe :). -->
  15. <link rel="alternate" type="application/atom+xml" title="Feed" href="/david/log/">
  16. <!-- Generated from https://realfavicongenerator.net/ such a mess. -->
  17. <link rel="apple-touch-icon" sizes="180x180" href="/static/david/icons2/apple-touch-icon.png">
  18. <link rel="icon" type="image/png" sizes="32x32" href="/static/david/icons2/favicon-32x32.png">
  19. <link rel="icon" type="image/png" sizes="16x16" href="/static/david/icons2/favicon-16x16.png">
  20. <link rel="manifest" href="/static/david/icons2/site.webmanifest">
  21. <link rel="mask-icon" href="/static/david/icons2/safari-pinned-tab.svg" color="#07486c">
  22. <link rel="shortcut icon" href="/static/david/icons2/favicon.ico">
  23. <meta name="msapplication-TileColor" content="#f0f0ea">
  24. <meta name="msapplication-config" content="/static/david/icons2/browserconfig.xml">
  25. <meta name="theme-color" content="#f0f0ea">
  26. <!-- Documented, feel free to shoot an email. -->
  27. <link rel="stylesheet" href="/static/david/css/style_2020-06-19.css">
  28. <!-- See https://www.zachleat.com/web/comprehensive-webfonts/ for the trade-off. -->
  29. <link rel="preload" href="/static/david/css/fonts/triplicate_t4_poly_regular.woff2" as="font" type="font/woff2" media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)" crossorigin>
  30. <link rel="preload" href="/static/david/css/fonts/triplicate_t4_poly_bold.woff2" as="font" type="font/woff2" media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)" crossorigin>
  31. <link rel="preload" href="/static/david/css/fonts/triplicate_t4_poly_italic.woff2" as="font" type="font/woff2" media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)" crossorigin>
  32. <link rel="preload" href="/static/david/css/fonts/triplicate_t3_regular.woff2" as="font" type="font/woff2" media="(prefers-color-scheme: dark)" crossorigin>
  33. <link rel="preload" href="/static/david/css/fonts/triplicate_t3_bold.woff2" as="font" type="font/woff2" media="(prefers-color-scheme: dark)" crossorigin>
  34. <link rel="preload" href="/static/david/css/fonts/triplicate_t3_italic.woff2" as="font" type="font/woff2" media="(prefers-color-scheme: dark)" crossorigin>
  35. <script type="text/javascript">
  36. function toggleTheme(themeName) {
  37. document.documentElement.classList.toggle(
  38. 'forced-dark',
  39. themeName === 'dark'
  40. )
  41. document.documentElement.classList.toggle(
  42. 'forced-light',
  43. themeName === 'light'
  44. )
  45. }
  46. const selectedTheme = localStorage.getItem('theme')
  47. if (selectedTheme !== 'undefined') {
  48. toggleTheme(selectedTheme)
  49. }
  50. </script>
  51. <meta name="robots" content="noindex, nofollow">
  52. <meta content="origin-when-cross-origin" name="referrer">
  53. <!-- Canonical URL for SEO purposes -->
  54. <link rel="canonical" href="https://hankchizljaw.com/wrote/honesty-is-the-best-policy/">
  55. <body class="remarkdown h1-underline h2-underline h3-underline hr-center ul-star pre-tick">
  56. <article>
  57. <header>
  58. <h1>Honesty is the best policy</h1>
  59. </header>
  60. <nav>
  61. <p class="center">
  62. <a href="/david/" title="Aller à l’accueil">🏠</a> •
  63. <a href="https://hankchizljaw.com/wrote/honesty-is-the-best-policy/" title="Lien vers le contenu original">Source originale</a>
  64. </p>
  65. </nav>
  66. <hr>
  67. <main>
  68. <p><strong>Update - 6 February, 2020</strong>: Gatsby have now clarified their position by deleting <em>“a single image is often bigger than a JavaScript bundle”</em>, only with no explanation on why. As is increasingly the case, <code>trust--</code>.</p>
  69. <p><hr/><p>There’s an article circulating, titled <a href="https://www.gatsbyjs.org/blog/2020-01-30-why-gatsby-is-better-with-javascript/">Why Gatsby is better with JavaScript</a>, which boils down as a justification for why the framework produces so much JavaScript output. This is fine and there are some good points in the article, but there’s one bit that I initially skimmed over, and spotted today (thanks, <a href="https://twitter.com/stowball/status/1224791020220510208">Matt</a>) which made me wince:</p><blockquote><p>“It’s also important to put the JavaScript bundle size in perspective. While it definitely can have a detrimental effect on performance, especially when it grows uncontrollably, a single image is often bigger than a JavaScript bundle.”</p></blockquote><p>It goes on to say that “It’s worth judging the website as a whole, not only how much JavaScript it ships”, which I wholeheartedly agree with, but the sentiment of the main quote is concerning and frankly, it’s completely false.</p><p>I urge you to read <a href="https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/javascript-startup-optimization">JavaScript Start-up Optimization</a> by <a href="https://addyosmani.com/">Addy Osmani</a>. It’s a brilliant article that explains the true cost of JavaScript really well. There’s a couple of takeaways that I want to highlight:</p><blockquote><p>“Spending a long time parsing/compiling code can heavily delay how soon a user can interact with your site. The more JavaScript you send, the longer it will take to parse and compile it before your site is interactive.”</p></blockquote><p>This is something that’s very important to remember and it’s one of the main contributors to my obsession with shipping as little JavaScript as possible— <a href="https://web.dev/interactive/">Time To Interactive</a>, which is how long after the initial request for a web page it takes for you to be able to interact with it. For heavy sites, this can be an eye-watering long time (hello news sites).</p><p>This is not an issue for me, because I am steeped in privilege with my top-spec MacBook Pro and iPhone 11, so generally, most sites—even ones with outrageous bundle sizes—tend to run fine. We should’t be building for people like me though, because people like me are the privileged minority. We should instead be optimizing for low-to-mid powered devices. One good way to test your sites against devices like this is <a href="https://webpagetest.org/easy">Webpage Test’s “easy” preset</a>.</p><p>Some other related advice is to not 100% rely on <a href="https://developers.google.com/web/tools/lighthouse">Lighthouse</a> scores. Lighthouse is a fantastic tool which gives you a good idea of how your website is performing, but it can also be misleading, as <a href="https://www.matuzo.at/blog/building-the-most-inaccessible-site-possible-with-a-perfect-lighthouse-score/">Manuel Matuzovic eloquently describes</a>.</p><p>Anyway, back to Addy’s article. Another takeaway from the article is this:</p><blockquote><p>“JavaScript and image bytes have very different costs. Images usually don’t block the main thread or prevent interfaces from getting interactive while being decoded and rasterized. JS however can delay interactivity due to parse, compile and execution costs.”</p></blockquote><p>This is what my issue with the Gatsby article is.</p><h2 id="heading-benefit-of-the-doubt">Benefit of the doubt<a href="#heading-benefit-of-the-doubt" class="heading-permalink"><span class="visually-hidden"> permalink</span><svg fill="currentColor" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24"><path d="M9.199 13.599a5.99 5.99 0 0 0 3.949 2.345 5.987 5.987 0 0 0 5.105-1.702l2.995-2.994a5.992 5.992 0 0 0 1.695-4.285 5.976 5.976 0 0 0-1.831-4.211 5.99 5.99 0 0 0-6.431-1.242 6.003 6.003 0 0 0-1.905 1.24l-1.731 1.721a.999.999 0 1 0 1.41 1.418l1.709-1.699a3.985 3.985 0 0 1 2.761-1.123 3.975 3.975 0 0 1 2.799 1.122 3.997 3.997 0 0 1 .111 5.644l-3.005 3.006a3.982 3.982 0 0 1-3.395 1.126 3.987 3.987 0 0 1-2.632-1.563A1 1 0 0 0 9.201 13.6zm5.602-3.198a5.99 5.99 0 0 0-3.949-2.345 5.987 5.987 0 0 0-5.105 1.702l-2.995 2.994a5.992 5.992 0 0 0-1.695 4.285 5.976 5.976 0 0 0 1.831 4.211 5.99 5.99 0 0 0 6.431 1.242 6.003 6.003 0 0 0 1.905-1.24l1.723-1.723a.999.999 0 1 0-1.414-1.414L9.836 19.81a3.985 3.985 0 0 1-2.761 1.123 3.975 3.975 0 0 1-2.799-1.122 3.997 3.997 0 0 1-.111-5.644l3.005-3.006a3.982 3.982 0 0 1 3.395-1.126 3.987 3.987 0 0 1 2.632 1.563 1 1 0 0 0 1.602-1.198z"/></svg></a></h2><p>I want to give Gatsby the benefit of the doubt on this. I want to believe it’s not a sinister attempt at self-justification by distributing a little mistruth that could cascade, much like the <a href="https://github.com/w3c/html/pull/331">myth that you can use multiple <code>&lt;h1&gt;</code> elements on a site</a>. I, of course, <a href="https://twitter.com/hankchizljaw/status/1224972729373405185">spat out my tea on Twitter when I saw this</a>, but <a href="https://twitter.com/hankchizljaw/status/1224976031163076610">added to the thread</a> that I appreciate the work that Gatsby are doing for Accessibility and improving client-driven JavaScript, by working on partial hydration. These are good things and the optimist in me is hoping that they take their <a href="https://www.crunchbase.com/organization/gatsby-e828#section-overview">sizeable VC funding</a> and apply it in becoming leaders in modern, performant frameworks.</p><p>I also think that there could a bit of naivety from the author of <a href="https://www.gatsbyjs.org/blog/2020-01-30-why-gatsby-is-better-with-javascript/">the article in question</a>, who might not be aware of the points raised in <a href="https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/javascript-startup-optimization">Addy’s writing</a>.</p><p>I’m trying to look at Gatsby in a more positive light, as I <a href="https://hankchizljaw.com/wrote/2019:-a-year-in-review/#heading-time-to-embrace-react-and-gatsby">mentioned in my 2019 year in review article</a>. I even built <a href="https://front-end-challenges.club/">Front-End Challenges Club</a> with Gatsby to better understand the workings of it and I must say, the developer experience was lovely. I’ll also be <a href="https://piccalil.li/course/lets-build-a-landing-page/">teaching a course on Piccalilli</a> using Gatsby as the core static-site generator. I still, of course, prefer <a href="//11ty.dev">Eleventy</a>, but it’s important that I’m fair with criticism and that actually using tools like Gatsby contributes to that.</p><p>This all boils down to trust. Trust is often not lost in single events but instead it is chipped away at. With the <a href="https://themejam.gatsbyjs.org/">rather problematic theme competition</a>, last year, which encouraged people to build an entire theme to win a conference ticket (hello, unpaid spec work) and then articles like this coming about: I can feel my own trust being chipped away at. It also doesn’t help that Gatsby is built with React, so by proxy, has a direct link to Facebook, which for those who know me well, will know that’s almost immediately in impossible barrier to get beyond.</p><p>But as I said when I was <a href="https://shoptalkshow.com/episodes/394/">lucky to be on the Shop Talk Show</a>: Gatsby is not going anywhere and will only get more popular, so I want to try to be productive with criticisms, with the hope that in turn, they make a big, positive impact on the web.</p></p>
  70. </main>
  71. </article>
  72. <hr>
  73. <footer>
  74. <p>
  75. <a href="/david/" title="Aller à l’accueil">🏠</a> •
  76. <a href="/david/log/" title="Accès au flux RSS">🤖</a> •
  77. <a href="http://larlet.com" title="Go to my English profile" data-instant>🇨🇦</a> •
  78. <a href="mailto:david%40larlet.fr" title="Envoyer un courriel">📮</a> •
  79. <abbr title="Hébergeur : Alwaysdata, 62 rue Tiquetonne 75002 Paris, +33184162340">🧚</abbr>
  80. </p>
  81. <template id="theme-selector">
  82. <form>
  83. <fieldset>
  84. <legend>Thème</legend>
  85. <label>
  86. <input type="radio" value="auto" name="chosen-color-scheme" checked> Auto
  87. </label>
  88. <label>
  89. <input type="radio" value="dark" name="chosen-color-scheme"> Foncé
  90. </label>
  91. <label>
  92. <input type="radio" value="light" name="chosen-color-scheme"> Clair
  93. </label>
  94. </fieldset>
  95. </form>
  96. </template>
  97. </footer>
  98. <script type="text/javascript">
  99. function loadThemeForm(templateName) {
  100. const themeSelectorTemplate = document.querySelector(templateName)
  101. const form = themeSelectorTemplate.content.firstElementChild
  102. themeSelectorTemplate.replaceWith(form)
  103. form.addEventListener('change', (e) => {
  104. const chosenColorScheme = e.target.value
  105. localStorage.setItem('theme', chosenColorScheme)
  106. toggleTheme(chosenColorScheme)
  107. })
  108. const selectedTheme = localStorage.getItem('theme')
  109. if (selectedTheme && selectedTheme !== 'undefined') {
  110. form.querySelector(`[value="${selectedTheme}"]`).checked = true
  111. }
  112. }
  113. const prefersColorSchemeDark = '(prefers-color-scheme: dark)'
  114. window.addEventListener('load', () => {
  115. let hasDarkRules = false
  116. for (const styleSheet of Array.from(document.styleSheets)) {
  117. let mediaRules = []
  118. for (const cssRule of styleSheet.cssRules) {
  119. if (cssRule.type !== CSSRule.MEDIA_RULE) {
  120. continue
  121. }
  122. // WARNING: Safari does not have/supports `conditionText`.
  123. if (cssRule.conditionText) {
  124. if (cssRule.conditionText !== prefersColorSchemeDark) {
  125. continue
  126. }
  127. } else {
  128. if (cssRule.cssText.startsWith(prefersColorSchemeDark)) {
  129. continue
  130. }
  131. }
  132. mediaRules = mediaRules.concat(Array.from(cssRule.cssRules))
  133. }
  134. // WARNING: do not try to insert a Rule to a styleSheet you are
  135. // currently iterating on, otherwise the browser will be stuck
  136. // in a infinite loop…
  137. for (const mediaRule of mediaRules) {
  138. styleSheet.insertRule(mediaRule.cssText)
  139. hasDarkRules = true
  140. }
  141. }
  142. if (hasDarkRules) {
  143. loadThemeForm('#theme-selector')
  144. }
  145. })
  146. </script>
  147. </body>
  148. </html>