<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Adriano Luz</title>
    <description>The latest articles on DEV Community by Adriano Luz (@decode64).</description>
    <link>https://dev.to/decode64</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F646232%2Fc1920c90-4ea8-4da4-89b5-f298686085d9.jpeg</url>
      <title>DEV Community: Adriano Luz</title>
      <link>https://dev.to/decode64</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/decode64"/>
    <language>en</language>
    <item>
      <title>Everything You Need To Know To Pass PageSpeed With A Perfect Score</title>
      <dc:creator>Adriano Luz</dc:creator>
      <pubDate>Tue, 20 Jul 2021 14:15:53 +0000</pubDate>
      <link>https://dev.to/decode64/everything-you-need-to-know-to-pass-pagespeed-with-a-perfect-score-4n23</link>
      <guid>https://dev.to/decode64/everything-you-need-to-know-to-pass-pagespeed-with-a-perfect-score-4n23</guid>
      <description>&lt;p&gt;How long do you wait for a page to load? Not much time, I guess.&lt;/p&gt;

&lt;p&gt;You are not the only one who doesn't like to wait a long time until a page loads. In fact, page loading performance is one of the most important factors for a good user experience on the web.&lt;/p&gt;

&lt;p&gt;As Jakob Nielsen says in this &lt;a href="https://www.nngroup.com/articles/website-response-times/"&gt;article&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A snappy user experience beats a glamorous one, for the simple reason that people engage more with a site when they can move freely and focus on the content instead of on their endless wait.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Page loading performance is so important that google now uses it as a &lt;a href="https://developers.google.com/search/blog/2021/04/more-details-page-experience"&gt;ranking factor&lt;/a&gt; in search results. In other words, your SEO now depends on your page performance too.&lt;/p&gt;

&lt;p&gt;Because of this, many developers are now trying to optimize their website metrics using google's PageSpeed Insights tool to get the best score possible.&lt;/p&gt;

&lt;p&gt;In this post I'll discuss everything you need to know to optimize page performance and get a perfect score on PageSpeed. First I'll present the main factors that affect page loading speed, then, the metrics that are used to measure page performance, the tools used to measure them and finally discuss some techniques to improve page performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  How The Browser Renders Web Pages
&lt;/h2&gt;

&lt;p&gt;Before optimizing web pages we need to understand the process of rendering pages to the screen.&lt;/p&gt;

&lt;p&gt;My &lt;a href="https://decode64.dev/from-html-to-the-screen-how-browsers-render-web-pages/"&gt;previous article&lt;/a&gt; presented an overview of how HTML and CSS files are parsed and combined to render a page on the screen. Let's briefly review this process considering the performance related aspects of it.&lt;/p&gt;

&lt;h3&gt;
  
  
  CSS And Render Block
&lt;/h3&gt;

&lt;p&gt;The process of rendering a web page in the browser starts by downloading the HTML file from a server. As soon as the browser receives the first bytes of the HTML it starts to parse it progressively to construct the DOM tree.&lt;/p&gt;

&lt;p&gt;During the DOM parsing process the parser can find a link tag to a CSS file. When this tag is found, the parser immediately dispatches a request to download the CSS file and continues to parse the HTML. The CSS download occurs in parallel with HTML parsing.&lt;/p&gt;

&lt;p&gt;Now imagine that the parser finished constructing the DOM but is still downloading CSS files. In this situation the browser can't render anything until all CSS is downloaded and parsed otherwise a page with no styling will be displayed to the user. Worse than that, the unstyled page would be displayed and updated as soon as all CSS is downloaded and parsed, causing what is called a &lt;strong&gt;flash of unstyled content&lt;/strong&gt; (FOUC).&lt;/p&gt;

&lt;p&gt;To avoid causing a FOUC, the browser has to wait for all CSS to be downloaded and parsed before displaying the page. For this reason we say that CSS is a &lt;strong&gt;render blocking&lt;/strong&gt; resource.&lt;/p&gt;

&lt;h3&gt;
  
  
  What About Javascript?
&lt;/h3&gt;

&lt;p&gt;During the HTML parsing the browser can also encounter &lt;code&gt;script&lt;/code&gt; tags. Like CSS, the browser dispatches a request to download the javascript file immediately but, instead of continuing the HTML parsing, it pauses until the javascript is downloaded and executed.&lt;/p&gt;

&lt;p&gt;The entire DOM construction process has to be paused because javascript can manipulate the DOM by adding or removing elements to it, thus altering the structure of the original DOM parsed from the HTML. For this reason javascript is considered a &lt;strong&gt;parser blocking&lt;/strong&gt; resource.&lt;/p&gt;

&lt;p&gt;Another important property from javascript is that it can also manipulate element styles. When any style manipulation call happens from javascript, the browser has to verify that all known CSS has been downloaded and parsed before allowing the script to execute the style reading or manipulation. If the CSS is not ready, the script execution will be paused until the CSS parsing is done to ensure that the script has the most up-to-date style information for the page.&lt;/p&gt;

&lt;p&gt;Quick recap:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CSS blocks HTML render&lt;/li&gt;
&lt;li&gt;Javascript blocks HTML parsing (and render)&lt;/li&gt;
&lt;li&gt;CSS blocks Javascript&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Improving Performance
&lt;/h2&gt;

&lt;p&gt;The main goal of website optimization is to improve the performance perceived by the users. The best way to accomplish this is by displaying the first useful bits of information (above the fold content) for users as fast as possible.&lt;/p&gt;

&lt;p&gt;Knowing how CSS and Javascript resources affect the process of HTML parsing we can now start to optimize our pages to avoid any render blocking and display the content above the fold faster. Let's explore some strategies that can be used to improve the page performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Remove Unused Resources
&lt;/h3&gt;

&lt;p&gt;The most obvious, but often difficult to implement strategy to improve website performance, is to remove unused content. This includes unused HTML, unused CSS and unused Javascript.&lt;/p&gt;

&lt;p&gt;The problem of unused content is that the HTML and CSS parsers will have to do additional work to parse the unused content even though they won't be painted. As for Javascript the problem is the same. The interpreter will still have to parse script code that won't be executed.&lt;/p&gt;

&lt;p&gt;By removing unused resources you can decrease the script, css and html size, thus improving the resource download time as well as requiring less work from CSS/HTML parsers and from the Javascript interpreter to render the page.&lt;/p&gt;

&lt;h3&gt;
  
  
  Embed Critical CSS
&lt;/h3&gt;

&lt;p&gt;This strategy consists in splitting CSS files into &lt;em&gt;critical&lt;/em&gt; and &lt;em&gt;non-critical&lt;/em&gt; and embedding the critical CSS in the page HTML files.&lt;/p&gt;

&lt;p&gt;The critical CSS consists of rules needed to render above the fold content while the non-critical CSS consists of rules used only by parts of the page that are not displayed immediately, like components rendered below the fold, modals and hidden menus.&lt;/p&gt;

&lt;p&gt;After identifying all the critical rules, a &lt;code&gt;style&lt;/code&gt; tag can be used to inline these rules directly into the HTML file. This will void a second network round trip by the browser to fetch the critical CSS. As an effect, the page rendering process won't be blocked by CSS download and the above the fold can be rendered much faster.&lt;/p&gt;

&lt;h3&gt;
  
  
  Lazy Load Non Critical CSS
&lt;/h3&gt;

&lt;p&gt;Since the non critical CSS is not required on the initial page load, it can safely be loaded after the above the initial fold content is rendered.&lt;/p&gt;

&lt;p&gt;To properly apply this strategy, a small javascript is required. The reason being that, as discussed before, any &lt;code&gt;link&lt;/code&gt; tag to a CSS resource will cause the browser to pause the render process until all the CSS is downloaded and parsed.&lt;/p&gt;

&lt;p&gt;The following javascript snippet can be used to load CSS files after the initial page load:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;link&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;link&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;link&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rel&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;stylesheet&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;link&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;href&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path/to/noncritical.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;link&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Basically it executes a script to insert the non critical css in the DOM and make the browser download, parse and apply the styles defined in the file. Note that this script will only be executed on the window &lt;code&gt;onload&lt;/code&gt; event. This is required to make sure that the initial page has been completely rendered before the non critical CSS is inserted, avoiding this new CSS to block the initial render.&lt;/p&gt;

&lt;h3&gt;
  
  
  Async Javascript Loading
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;script&lt;/code&gt; tag supports two attributes that are useful to load scripts without blocking the HTML parser. These attributes are &lt;code&gt;async&lt;/code&gt; and &lt;code&gt;defer&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Both attributes can be used to tell the browser to load script files in background while the DOM is constructed. The main difference between these two attributes is the moment the downloaded script will be executed.&lt;/p&gt;

&lt;p&gt;Scripts loaded with &lt;code&gt;defer&lt;/code&gt; are executed only after the HTML parsing is done. For this reason, &lt;code&gt;defer&lt;/code&gt; scripts won't block parsing.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Async&lt;/code&gt; scripts, on the other hand, are executed as soon as they are available. If the browser finishes downloading an &lt;code&gt;async&lt;/code&gt; script while the HTML is being parsed, it will pause the parsing to execute the script.&lt;/p&gt;

&lt;p&gt;For this reason &lt;code&gt;defer&lt;/code&gt; should be preferred over &lt;code&gt;async&lt;/code&gt; to load javascript.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resource Preloading
&lt;/h3&gt;

&lt;p&gt;The resource preloading allows the browser to dispatch a request to download a resource that will be used soon. This way, the resource is already available when the browser needs it.&lt;/p&gt;

&lt;p&gt;Resource preloading works with any kind of resource like CSS, javascript, images and even json fetched from an API.&lt;/p&gt;

&lt;p&gt;The following tag is used to preload resources. Note that you should specify the kind of resource you're loading in the &lt;code&gt;as&lt;/code&gt; attribute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"preload"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"style.css"&lt;/span&gt; &lt;span class="na"&gt;as=&lt;/span&gt;&lt;span class="s"&gt;"style"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The preloading is particularly useful to tell the browser to download the non critical CSS before it is actually needed. That speeds up the non critical CSS processing without impacting the critical part of the page rendering.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use Compression
&lt;/h3&gt;

&lt;p&gt;After tackling all the basic page render blocking strategies presented above, some additional work can be done to ensure that critical resources are loaded as fast as possible.&lt;/p&gt;

&lt;p&gt;One of them is by using HTTP compression. All current browsers support &lt;code&gt;gzip&lt;/code&gt; and &lt;code&gt;brotli&lt;/code&gt; compression. It's also easy to find tools to allow your server to compress files before sending them to the browser.&lt;/p&gt;

&lt;h3&gt;
  
  
  Improve Server Response Time
&lt;/h3&gt;

&lt;p&gt;The idea is simple. The faster a server can deliver the content to the browser, the sooner the browser can start parsing and rendering it.&lt;/p&gt;

&lt;p&gt;However this is highly dependent on the server infrastructure and tools used to build the site. Some ideas to improve the server speed includes optimizing SQL queries, finding and fixing slow code and using caching when possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Performance Metrics
&lt;/h2&gt;

&lt;p&gt;It is essential for any performance improvement to have a set of standard metrics to measure if the optimizations are returning a positive effect. Let's take a look at the current three most important performance metrics for web performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Largest Contentful Paint (LCP)
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;largest contentful paint&lt;/em&gt; metric represents the time between the initial request to load a page and the paint of the largest page element above the fold. The largest element can be an image, a video poster, a background defined in css with &lt;code&gt;url()&lt;/code&gt; or a block of text.&lt;/p&gt;

&lt;p&gt;It is very common to have an image as the page LCP element. If that's the case, the resource preloading can be used to start loading it sooner. Also, it is important to resize all images to a dimension closer to the final displayed size to decrease the file size. Image metadata removal can be helpful too.&lt;/p&gt;

&lt;p&gt;This metric is part of the core web vitals and has an impact on SEO ranking. A measured time of 2.5 seconds or less is considered a good value.&lt;/p&gt;

&lt;h3&gt;
  
  
  First Input Delay (FID)
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;first input delay&lt;/em&gt; metric represents the time between the first user interaction with a site and the time the browser responds to the interaction.&lt;/p&gt;

&lt;p&gt;The main factor that impacts on FID is the time taken by javascript to setup all interaction events for the page. For this reason it's important to execute the minimum possible javascript code at the page load to avoid blocking the setup of input events.&lt;/p&gt;

&lt;p&gt;This metric is also part of the core web vitals and impacts your SEO ranking. A measured time of 100ms or less is considered a good value.&lt;/p&gt;

&lt;h3&gt;
  
  
  Time To First Byte (TTFB)
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;time to first byte&lt;/em&gt; measures the time between the initial request to load a page and the first byte received as a response by the browser. It is a good metric to measure the server response time.&lt;/p&gt;

&lt;p&gt;This metric is not part of the core web vitals and doesn't impact SEO ranking directly. But a good TTFB will help to get a good score on all other performance metrics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measuring Performance
&lt;/h2&gt;

&lt;h3&gt;
  
  
  PageSpeed
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://developers.google.com/speed/pagespeed/insights/"&gt;PageSpeed&lt;/a&gt; is the main tool to measure website performance. It uses lighthouse to measure and report many metrics and, based on the results, presents a few insights.&lt;/p&gt;

&lt;p&gt;It is important to note that the score given by this tool is not what is used by google as a ranking factor. Google, instead, uses data collected from real users (called "field data"). The PageSpeed report can display the field data collected by Google depending on the site's size and relevance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Chrome Lighthouse
&lt;/h3&gt;

&lt;p&gt;Another way to get a performance report is through the lighthouse tab on chrome developer tools. It can be accessed by right clicking on the page then selecting "Inspect" and navigating to the "Lighthouse" tab.&lt;/p&gt;

&lt;p&gt;The main advantage of this tool is that it can be used to measure the performance of sites that are still in development and running on environments not accessible from the internet.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting Data From Field
&lt;/h3&gt;

&lt;p&gt;PageSpeed and Lighthouse are good tools to get an overview of a website's performance. But the only way to know the real performance is by measuring it in the field.&lt;/p&gt;

&lt;p&gt;Google provides a &lt;a href="https://github.com/GoogleChrome/web-vitals"&gt;javascript library&lt;/a&gt; to measure LCP, FID, TTFB and a few other metrics directly from the user's perspective. This script can be used to collect all the necessary data and send them to a server for processing and reporting.&lt;/p&gt;

&lt;p&gt;It is particularly important to measure the web vitals metrics from real users since this is what is used as a ranking factor by google.&lt;/p&gt;

&lt;h2&gt;
  
  
  In Conclusion
&lt;/h2&gt;

&lt;p&gt;Website optimization is a complex task. I hope this guide can help you to optimize your website, get a good score on pagespeed and improve the SEO ranking of your pages. If you have any questions, comments or feedback, reach me on twitter at &lt;a href="https://twitter.com/decode64"&gt;@decode64&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>performance</category>
      <category>pagespeed</category>
      <category>ux</category>
    </item>
    <item>
      <title>From HTML To The Screen: How Browsers Render Web Pages
</title>
      <dc:creator>Adriano Luz</dc:creator>
      <pubDate>Mon, 14 Jun 2021 14:41:27 +0000</pubDate>
      <link>https://dev.to/decode64/from-html-to-the-screen-how-browsers-render-web-pages-48m2</link>
      <guid>https://dev.to/decode64/from-html-to-the-screen-how-browsers-render-web-pages-48m2</guid>
      <description>&lt;p&gt;The most basic function of a web browser is to get a html file, along with&lt;br&gt;
an optional css, interpret them and display a page to the user. It is a complex&lt;br&gt;
process but it is based on basic principles that any developer can understand.&lt;/p&gt;

&lt;p&gt;In this post we will learn the basics of html rendering and discuss how we can&lt;br&gt;
improve our html and css from what we learned.&lt;/p&gt;

&lt;p&gt;Let's get right to it!&lt;/p&gt;
&lt;h2&gt;
  
  
  Constructing the DOM
&lt;/h2&gt;

&lt;p&gt;After downloading the html file from the web, the first step taken by the browser&lt;br&gt;
is to construct the DOM based on this file.&lt;/p&gt;

&lt;p&gt;The DOM (Document Object Model) is the internal browser representation of a page&lt;br&gt;
and it is represented as a tree.&lt;/p&gt;

&lt;p&gt;To better understand how the DOM is built let's use the following HTML as an&lt;br&gt;
example and go over each step of the DOM construction for this file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"main.css"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;From HTML To The Screen: How Browsers Render Web Pages&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Lorem Ipsum&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Dolor sit amet.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To construct the DOM tree, the browser has to first read each character of the&lt;br&gt;
html text file and transform this text into a sequence of tokens.&lt;/p&gt;

&lt;p&gt;A token is a representation of a piece of text that has a special meaning and&lt;br&gt;
specific rules about how to handle it.&lt;/p&gt;

&lt;p&gt;The example HTML above will produce the following sequence of tokens:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;HTML&lt;/code&gt; &amp;gt; &lt;code&gt;HEAD&lt;/code&gt; &amp;gt; &lt;code&gt;LINK&lt;/code&gt; &amp;gt; &lt;code&gt;TITLE&lt;/code&gt; &amp;gt; &lt;code&gt;TEXT&lt;/code&gt; &amp;gt; &lt;code&gt;/TITLE&lt;/code&gt; &amp;gt; &lt;code&gt;/HEAD&lt;/code&gt; &amp;gt; &lt;code&gt;BODY&lt;/code&gt; &amp;gt; &lt;code&gt;H1&lt;/code&gt; &amp;gt; &lt;code&gt;TEXT&lt;/code&gt; &amp;gt; &lt;code&gt;/H1&lt;/code&gt; &amp;gt;&lt;br&gt;
&lt;code&gt;P&lt;/code&gt; &amp;gt; &lt;code&gt;TEXT&lt;/code&gt; &amp;gt; &lt;code&gt;/P&lt;/code&gt; &amp;gt; &lt;code&gt;/BODY&lt;/code&gt; &amp;gt; &lt;code&gt;/HTML&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Note that not only HTML tags are identified by tokens. The text content from the&lt;br&gt;
&lt;code&gt;title&lt;/code&gt;, &lt;code&gt;h1&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt; tags generate a &lt;code&gt;TEXT&lt;/code&gt; token to identify them.&lt;/p&gt;

&lt;p&gt;After transforming the HTML text into tokens, the browser scans each token and&lt;br&gt;
arranges them in the DOM tree structure. The browser knows how to create&lt;br&gt;
this structure based on the order of these tokens and the rules for each token.&lt;/p&gt;

&lt;p&gt;Each node of the DOM tree is also used to store additional information about that node&lt;br&gt;
like tag attributes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AbGiK5-a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://decode64.dev/assets/2-1-dom-tree.svg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AbGiK5-a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://decode64.dev/assets/2-1-dom-tree.svg" alt="DOM tree for the example HTML"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The entire process can be represented by this simple image:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PcsGov2---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://decode64.dev/assets/2-2-parsing-steps.svg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PcsGov2---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://decode64.dev/assets/2-2-parsing-steps.svg" alt="DOM construction steps"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The CSSOM
&lt;/h2&gt;

&lt;p&gt;The CSSOM is a structure similar to the DOM that is constructed by the browser&lt;br&gt;
to store the css information for a page.&lt;/p&gt;

&lt;p&gt;Like the DOM, the CSSOM is constructed as a tree and the steps required&lt;br&gt;
to generate the CSSOM from a css file are the same as the DOM.&lt;/p&gt;

&lt;p&gt;The file is read character by character to generate tokens that will be later&lt;br&gt;
arranged in a tree structure.&lt;/p&gt;

&lt;p&gt;Let's have a look how the browser will construct the CSSOM for the following css.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;14px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;25px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;span&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="nt"&gt;span&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The tree structure of the CSSOM is constructed from the most generic to the most&lt;br&gt;
specific rule.&lt;/p&gt;

&lt;p&gt;Each node of the CSSOM contains the css rule defined by the css in addition to&lt;br&gt;
rules inherited from parent nodes. This rule inheritance is also called "cascading"&lt;br&gt;
and that's where the name Cascading Style Sheets comes from.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jeVBM-jj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://decode64.dev/assets/2-3-cssom-tree.svg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jeVBM-jj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://decode64.dev/assets/2-3-cssom-tree.svg" alt="DOM construction steps"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example above it's possible to see that the &lt;code&gt;font-size&lt;/code&gt; rule defined for&lt;br&gt;
the &lt;code&gt;body&lt;/code&gt; is cascaded down to &lt;code&gt;p&lt;/code&gt; and &lt;code&gt;span&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Another interesting thing to note in this example is the rule overriding. The css&lt;br&gt;
defines that all &lt;code&gt;span&lt;/code&gt; elements should be &lt;code&gt;red&lt;/code&gt;. But all &lt;code&gt;span&lt;/code&gt; that are inside a &lt;code&gt;p&lt;/code&gt;&lt;br&gt;
tag will be rendered green because a more specific rule &lt;code&gt;p span&lt;/code&gt; overrides the&lt;br&gt;
initial rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Render Tree
&lt;/h2&gt;

&lt;p&gt;After creating the DOM tree and the CSSOM tree the browser combines these trees&lt;br&gt;
into a new tree called the "render tree".&lt;/p&gt;

&lt;p&gt;The render tree will contain only nodes that need to be rendered by the browser.&lt;br&gt;
DOM nodes representing tags like &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; tags won't be present in&lt;br&gt;
the render tree. Nodes with css rules like &lt;code&gt;display: none&lt;/code&gt; won't be present either.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layout Calculation
&lt;/h3&gt;

&lt;p&gt;In this phase the browser will read the render tree starting on the root node&lt;br&gt;
and will traverse each node of the tree to calculate the exact size and position&lt;br&gt;
in pixels of every html element on the page.&lt;/p&gt;

&lt;p&gt;This step is necessary because positioning, widths and heights can be defined in&lt;br&gt;
the css using relative units like &lt;code&gt;%&lt;/code&gt; or &lt;code&gt;em&lt;/code&gt; and must be converted to absolute&lt;br&gt;
pixels equivalent based on the browser viewport size.&lt;/p&gt;

&lt;h3&gt;
  
  
  Painting
&lt;/h3&gt;

&lt;p&gt;And finally, the last step. With every position defined in exact pixel units the&lt;br&gt;
browser can start painting each pixel of the screen to render the page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optimizing The Rendering Process
&lt;/h2&gt;

&lt;p&gt;The page rendering process is long and complex. Based on what we learned so far&lt;br&gt;
there are 3 easy optimizations we can do to help the browser to go trough this&lt;br&gt;
entire process and display the page as fast as possible to our users.&lt;/p&gt;

&lt;p&gt;The first is, remove all unnecessary html and css from your pages. Unnecessary html&lt;br&gt;
and css that won't ever be displayed makes the browser do a lot of useless&lt;br&gt;
work.&lt;/p&gt;

&lt;p&gt;That's because the browser will parse and create the DOM and CSSOM trees&lt;br&gt;
for all html and css and will only detect what should be displayed or hidden&lt;br&gt;
in the render tree construction step.&lt;/p&gt;

&lt;p&gt;Second, improve your server response time. By getting the html and css files&lt;br&gt;
earlier, the browser can start the whole rendering process earlier too.&lt;/p&gt;

&lt;p&gt;Third, reduce the html and css file sizes. That can be done by removing unused&lt;br&gt;
html/css or by using file compression at the backend. This will reduce the&lt;br&gt;
time needed for the browser to download all the necessary files and will&lt;br&gt;
enable it to start the parsing earlier.&lt;/p&gt;

&lt;h2&gt;
  
  
  In Conclusion
&lt;/h2&gt;

&lt;p&gt;Browsers are a really complex piece of software.&lt;/p&gt;

&lt;p&gt;But some basic knowledge of how the browsers work, specially how they render&lt;br&gt;
web pages are helpful to be able to create better pages.&lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
    </item>
    <item>
      <title>Tips For Designing A Developer Blog</title>
      <dc:creator>Adriano Luz</dc:creator>
      <pubDate>Wed, 09 Jun 2021 12:36:40 +0000</pubDate>
      <link>https://dev.to/decode64/tips-for-designing-a-developer-blog-1hmn</link>
      <guid>https://dev.to/decode64/tips-for-designing-a-developer-blog-1hmn</guid>
      <description>&lt;p&gt;I'm starting a new blog. And what a better way to start it than talking about how I've built it?&lt;/p&gt;

&lt;p&gt;Usually developers write their first "Hello World" blog post describing all the languages, frameworks&lt;br&gt;
and coding techniques they have used to build the blog.&lt;/p&gt;

&lt;p&gt;But unlike all developers, I won't describe how I built it technically.&lt;/p&gt;

&lt;p&gt;First because I used a quite ordinary set of tools: jekyll served from github pages.&lt;/p&gt;

&lt;p&gt;Second, because I want to use this first post to set the expectation of what kind of topic intend&lt;br&gt;
to write about in this blog.&lt;/p&gt;

&lt;p&gt;In this post I'll discuss how I built my blog from a design perspective and give some tips about&lt;br&gt;
designing personal blogs for developers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's Talk About Design
&lt;/h2&gt;

&lt;p&gt;The goal of any blog is to keep the reader's attention to be able to deliver a message or knowledge&lt;br&gt;
effectively. For this reason you'll notice that my blog has a really simple UI. Some may&lt;br&gt;
call it "minimalist".&lt;/p&gt;

&lt;p&gt;It is minimalist in the sense that all that I've done in the UI was just adding a few sprinkles on top&lt;br&gt;
of what browsers render naturally without any styling. You can see that not much changes if&lt;br&gt;
you render my blog without CSS.&lt;/p&gt;

&lt;p&gt;The few changes added on top of a raw HTML were added with the goal to improve as&lt;br&gt;
much as possible the reading experience.&lt;/p&gt;

&lt;p&gt;Here are the 7 main design elements that I used to build a better blog.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Limit Content Width
&lt;/h3&gt;

&lt;p&gt;Perhaps the most important tip. Limit the width of the text.&lt;/p&gt;

&lt;p&gt;Long lines are really difficult to read and to keep track of. When readers reach the end of the&lt;br&gt;
current line they won't have the beginning of the line in their field of view if the line is too long.&lt;br&gt;
This makes it difficult to know which line is the next.&lt;/p&gt;

&lt;p&gt;It will cause frustration and can make readers lose interest in the content&lt;br&gt;
only because the text is hard to read.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Don't Add Distractions In The Middle Of The Text
&lt;/h3&gt;

&lt;p&gt;No pop-ups, no animations, no ads. Nothing. You want your readers to stay focused on the text to be&lt;br&gt;
able to communicate your ideas effectively.&lt;/p&gt;

&lt;p&gt;It is very likely that readers will already have other sources of distraction while reading your content.&lt;br&gt;
Don't add another one.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Add Code Highlighting
&lt;/h3&gt;

&lt;p&gt;Code highlighting is one of the best tools for software development and can be integrated&lt;br&gt;
into your blog to make code blocks easier to read.&lt;/p&gt;

&lt;p&gt;It is also important to add highlighting for inline code snippets. Something simple like&lt;br&gt;
a text with different color using a monospace font is enough to make the inline code&lt;br&gt;
distinguishable from the normal text.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Display The Post Date At The Top
&lt;/h3&gt;

&lt;p&gt;One of the most frustrating experiences for a software developer is to read an entire blog post,&lt;br&gt;
test the examples and ideas, fail to make them work and, after a lot of debugging, discover&lt;br&gt;
that the post is outdated.&lt;/p&gt;

&lt;p&gt;For this reason, any blog, especially blogs focused on software development, should include the date&lt;br&gt;
of the post at the beginning of the page.&lt;/p&gt;

&lt;p&gt;If you have an outdated post that you know that doesn't work anymore, add a disclaimer at the beginning&lt;br&gt;
of the text. Another idea is to write a new post and add the link to the updated version on the old one.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Tag Your Posts
&lt;/h3&gt;

&lt;p&gt;Tags are a simple way to give additional context about a blog post theme. But don't add too many of&lt;br&gt;
them to a blog post.&lt;/p&gt;

&lt;p&gt;Many tags to a single post means that the content doesn't have a clear focus or some of the tags&lt;br&gt;
are irrelevant. Either case is bad for readers.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Avoid Default Visual Themes And Templates
&lt;/h3&gt;

&lt;p&gt;A unique visual style to the blog allows the readers to quickly recognize that they are reading&lt;br&gt;
your blog. The blog UI is part of your branding.&lt;/p&gt;

&lt;p&gt;For this reason, avoid default themes or themes that are used by many other developers. Try to come&lt;br&gt;
up with something new.&lt;/p&gt;

&lt;p&gt;Keep in mind that the blog visuals should be simple. Remember, the goal is to improve the&lt;br&gt;
experience of the readers and not to distract them with fancy CSS.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Call To Action At The End
&lt;/h3&gt;

&lt;p&gt;If a reader reached the end of your content, congratulations!&lt;/p&gt;

&lt;p&gt;It means that the reader enjoyed your content and you can use this opportunity to guide them to a place&lt;br&gt;
where they can learn more about the topic.&lt;/p&gt;

&lt;p&gt;You can add a link to a related post or a link to your social media where the reader can ask you questions&lt;br&gt;
or give feedback about your content.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading Experience
&lt;/h2&gt;

&lt;p&gt;Everything is designed for someone to accomplish a specific goal. When designing a blog for developers&lt;br&gt;
we should think how the design will improve the reading experience and, as a consequence, help the&lt;br&gt;
readers to learn as much as possible.&lt;/p&gt;

&lt;p&gt;Are you designing a blog? What design element have you added to improve the reader’s experience?&lt;/p&gt;

</description>
      <category>design</category>
      <category>ux</category>
    </item>
  </channel>
</rss>
