<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Golia Simone on Medium]]></title>
        <description><![CDATA[Stories by Golia Simone on Medium]]></description>
        <link>https://medium.com/@golia.simone?source=rss-e0df3230de40------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OT6yv-setEoLNas7E3M3pQ@2x.jpeg</url>
            <title>Stories by Golia Simone on Medium</title>
            <link>https://medium.com/@golia.simone?source=rss-e0df3230de40------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 08:44:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@golia.simone/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Claude Code: do you really need an Agent for every technology?]]></title>
            <link>https://medium.com/@golia.simone/claude-code-do-you-really-need-an-agent-for-every-technology-e5ec2f437015?source=rss-e0df3230de40------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5ec2f437015</guid>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[agentic-ai-architecture]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[skills]]></category>
            <dc:creator><![CDATA[Golia Simone]]></dc:creator>
            <pubDate>Tue, 11 Aug 2026 06:01:01 GMT</pubDate>
            <atom:updated>2026-08-11T06:01:01.742Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Pzyaz60Qs8VXSud-LTxQA.png" /></figure><p>In the <a href="https://medium.com/@golia.simone/claude-code-do-you-actually-know-the-difference-between-agents-and-skills-2b8108bd1ead">previous post</a> I wrote that building an agent for every procedure was the mistake I started from.</p><p>One question was left open, and I ran into it on the first project with two different stacks in play: does the same apply when the technology changes?</p><p>Picture a developer working across projects: an Angular portal for client X, a ReactJS portal for client Y. There are two ways to set this up.</p><pre>Frontend Agent<br>├── Angular Skill<br>├── React Skill<br>├── Testing Skill<br>└── Accessibility Skill</pre><pre>Angular Agent<br>├── Angular Skill<br>├── Testing Skill<br>└── Accessibility Skill<br><br>React Agent<br>├── React Skill<br>├── Testing Skill<br>└── Accessibility Skill</pre><p>Both architectures could work. So which one do you pick?</p><h3>When a single Frontend Agent makes sense</h3><p>You can keep one Frontend Agent when the workflow is essentially the same:</p><ul><li>Analyze the project</li><li>Identify the framework</li><li>Analyze the problem</li><li>Apply the relevant expertise</li><li>Change the code</li><li>Run the tests</li><li>Review</li></ul><p>With a single workflow this is the better fit, because the agent establishes one thing only:</p><blockquote>“You are a Frontend Engineer, and this is how you work.”</blockquote><p>The Angular and React skills tell it how to work on that specific technology.</p><h4>When splitting Angular and React makes sense</h4><p>Now suppose you want two specialists following two separate workflows.</p><p><strong>Angular Agent</strong></p><pre>You are an Angular specialist.<br><br>You must:<br>- follow Angular best practices<br>- think in terms of standalone components<br>- use Signals where appropriate<br>- consider RxJS<br>- review dependency injection<br>- check Angular routing<br>- use the Angular CLI<br>- run Angular tests</pre><p><strong>React Agent</strong></p><pre>You are a React specialist.<br><br>You must:<br>- follow React best practices<br>- consider hooks<br>- handle state<br>- analyze rendering<br>- consider Server Components<br>- use React Testing Library<br>- analyze performance</pre><p>At this point you’re not just swapping knowledge.</p><p>You’re defining two specialists with different workflows and different decision criteria.</p><h4>So which one?</h4><p>There’s nothing wrong with building an Agent per technology, or with keeping just one. The problem starts when technology becomes the main criterion you split your Agents by.</p><p>The question to ask is:</p><blockquote><em>“Do Angular and React call for different responsibilities, or simply for different knowledge?”</em></blockquote><p>If only the knowledge changes, a Skill is usually the better fit.</p><p>Multiplying agents by technology means multiplying responsibilities. And if you want to maintain a cross-cutting concern like accessibility, you’ll have to update it on every agent you created. With a separate skill, that expertise is reusable not only by the subagent, but potentially by Claude’s main agent too.</p><p>Once your agents have a single responsibility, cramming all the technology knowledge inside one of them turns it into a mega-prompt. Which is exactly what Skills help you avoid: separating specialized knowledge from the Agent’s responsibility.</p><h4>How does Claude Code actually behave here?</h4><p>When you ask Claude Code something, the request lands on the Main Agent. Say you ask it:</p><blockquote>Review this component and tell me if anything’s wrong.</blockquote><p>If you have an Angular skill and a React skill:</p><pre>Main Agent<br>     │<br>     ├── Angular Skill<br>     │<br>     └── React Skill</pre><p>the Main Agent can apply that expertise directly. If instead you have:</p><pre>Main Agent<br>     │<br>     ├── Angular Agent<br>     │<br>     └── React Agent</pre><p>a new layer of delegation comes into play: the Main Agent has to hand the work to the Angular Agent, which runs its own workflow and returns the result. That’s only worth it if you want to delegate a task, not if you simply want to reuse knowledge.</p><p>If you asked instead:</p><blockquote>Review this Angular architecture and propose a refactoring strategy.</blockquote><p>the task is considerably more complex, and here an agent earns its place.</p><h4>Why not delegate everything to subagents?</h4><p>For a simple task, skipping the subagent has real advantages. It doesn’t mean subagents are “worse”: it means they add a layer of orchestration that is pure overhead when you don’t need it.</p><p>Delegating a task to a subagent requires a context switch. The Main Agent already knows:</p><ul><li>what you asked;</li><li>what it was doing;</li><li>which files it changed;</li><li>what decisions it made;</li><li>the context of the conversation.</li></ul><p>When you delegate, the subagent has to receive enough context to do the job: so you pay the tokens for the delegation and for the context it needs.</p><p>A context switch pays off once heavy context has piled up in the Main Agent. Picture 50/100k tokens of conversation, and at that point asking:</p><blockquote>Run a security audit on the frontend.</blockquote><p>Rather than piling everything further into the Main Agent, it’s worth delegating and letting an agent work on a smaller context, specialized for the task.</p><h4>So, for Angular and React</h4><p>If you have:</p><pre>Main Agent<br>├── Angular Skill<br>└── React Skill</pre><p>the Main Agent can pick the expertise it needs without spinning up a new context.<br>If you have:</p><pre>Main Agent<br>├── Angular Agent<br>└── React Agent</pre><p>what you’re saying is: when I work with Angular or React, I want the work delegated to a specialist with its own context.</p><p>It isn’t cheaper or more expensive in absolute terms. It’s a different architecture.</p><p>The rule of thumb: <strong>Skill when you want to add knowledge to the current context, Subagent when you want a separate context to carry out a task.</strong></p><p>In the next post we’ll look at how agents are actually configured and orchestrated, with hands-on examples.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5ec2f437015" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Claude Code: do you actually know the difference between Agents and Skills?]]></title>
            <link>https://medium.com/@golia.simone/claude-code-do-you-actually-know-the-difference-between-agents-and-skills-2b8108bd1ead?source=rss-e0df3230de40------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b8108bd1ead</guid>
            <category><![CDATA[ai-skills]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[claude-code]]></category>
            <dc:creator><![CDATA[Golia Simone]]></dc:creator>
            <pubDate>Sun, 09 Aug 2026 15:46:21 GMT</pubDate>
            <atom:updated>2026-08-09T15:46:21.869Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r1z9S7Oi61vq9bT5OFVWog.png" /><figcaption>AI Agents vs Skills</figcaption></figure><p>Most people start using Claude Code by building an Agent for almost everything. Then it hits them: when all you have is a hammer, everything looks like a nail.</p><p>I made that mistake myself, and it’s the reason this post exists. It’s for anyone who wants to set up something that actually speeds up their projects, without wading through documentation that often creates more confusion than clarity.</p><p>So let’s start with what agents are, and what skills are.</p><h3>What is an AI agent?</h3><p>Imagine asking:</p><blockquote>Analyze this Angular project.</blockquote><p>A chatbot tells you <strong><em>how</em></strong> to analyze it. An agent analyzes it:</p><ul><li>reads the repository structure;</li><li>identifies frameworks and dependencies;</li><li>maps out routing and components;</li><li>checks how state is managed;</li><li>inspects the API calls;</li><li>isolates architectural problems;</li><li>writes a report.</li></ul><p>The difference isn’t the quality of the answer. It’s that the agent takes action.<br>Think of an AI agent as a specialist: it’s given a goal, reasons about how to reach it, uses tools, and acts on its own. Its main components are:</p><ul><li><strong>Goal</strong> — what it needs to achieve</li><li><strong>Mode</strong> — the reasoning engine</li><li><strong>Instructions</strong> — how it should behave</li><li><strong>Tools </strong>— what it’s allowed to use</li><li><strong>Memory/Context</strong> — what it keeps or retrieves</li><li><strong>Actions</strong> — what it can actually do</li><li><strong>Feedback loop</strong> — checks the result and corrects course when needed</li></ul><p>At this point I always get the same question: <strong>”if an agent can do all that, what are skills for?”</strong></p><h3>What is a skill?</h3><p>Back to the example. You have a Security Agent, and you ask it:</p><blockquote>Check my portal for XSS vulnerabilities.</blockquote><p>The agent knows how to navigate code. But “look for XSS” isn’t an instruction, it’s a headline. Which sinks to check. Which frameworks already escape output for you. What counts as a false positive. How the report should be structured. You either explain all of that in the prompt every single time, or you write it down once in a skill.</p><p>A skill is a specialized competence that teaches an agent how to carry out a specific task, giving it the knowledge, the rules and the procedure to get it right.</p><p>The part that trips people up is how a skill gets picked. You don’t pick it. The model reads the intent behind your request, matches it against the skills available, spots the word “XSS” and decides: “to handle this I need the XSS Analysis Skill.” Only then are the instructions in that skill file loaded, and the agent runs the procedure.</p><p>Which leads somewhere counterintuitive: <strong>a skill’s description carries as much weight as its content.</strong> It’s the only part the model reads when deciding whether to open it. A brilliant skill with a vague description will never get invoked.</p><h3>The real dividing line is context</h3><p>Skills and agents look like they overlap. Both are instruction files. Both are reusable. Both can be invoked automatically. The practical difference is somewhere else: <strong>where the work ends up.</strong></p><p>A skill runs in the context you’re already working in. It sees the conversation, it sees what you did before, and whatever it produces stays there with you.</p><p>A subagent starts from a separate context. It can’t see your conversation, only the task you hand it. It works on its own, and returns a result to the parent, not everything it had to read to get there.</p><p>Almost everything else follows from that one difference:</p><ul><li>grunt work: opening twenty files, exploring, discarding belongs in an <strong>agent</strong>, so the noise never reaches your conversation;</li><li>method: how something is done, which standards to follow belongs in a <strong>skill</strong>, because you need it exactly where you’re working.</li></ul><h3>How to choose, in practice</h3><p>Two questions, in this order.</p><p><strong>Am I teaching a method, or delegating a job?</strong> <br>If the answer is “here’s how commit messages are written in this repo”, it’s a skill. If it’s “go through these logs and tell me what broke”, it’s an agent.</p><p><strong>Do I need the output in my context, or just the summary?<br></strong>If you have to keep working through it line by line, keep it where you are: skill. If the conclusion is enough, delegate: agent.</p><p>The setup that works best, though, is neither one nor the other. It’s a specialized agent that uses skills internally to know how to do things. The Security Agent above is exactly that. It was never agents versus skills.</p><h3>The mistake I started from</h3><p>The mistake I made, and the one I see most often, is building an agent for every procedure. An agent for commits. An agent for style review. An agent for naming conventions.</p><p>They work. But you pay the worst possible price: you spin up a separate context for something you needed right where you were standing, and you get back a summary of work you wanted to read in full.</p><p>They were all skills.</p><p>Telling the two apart is the easy part. Getting the setup wrong costs you nothing today and quite a lot once you have a dozen of these files.</p><p>In the next posts I’ll go through how to configure agents and skills properly, and how to orchestrate them so they work together instead of duplicating each other.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b8108bd1ead" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CDN: What It Is, Why Use It, and How to Integrate It into an Angular App]]></title>
            <link>https://medium.com/@golia.simone/cdn-what-it-is-why-use-it-and-how-to-integrate-it-into-an-angular-app-4f7fcee27a52?source=rss-e0df3230de40------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f7fcee27a52</guid>
            <category><![CDATA[caching]]></category>
            <category><![CDATA[cdn]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[Golia Simone]]></dc:creator>
            <pubDate>Sun, 24 Aug 2025 17:05:59 GMT</pubDate>
            <atom:updated>2025-08-24T17:05:59.031Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nj4pYRD-3mwnqZoUZRtIXQ.png" /></figure><p>When developing web applications, we often focus on code and features. But what happens when our users are on the other side of the world? Loading times can become slow, especially if we’re dealing with large JavaScript files or high-resolution images. This is where a <strong>CDN</strong> comes into play.</p><h3>What Is a CDN?</h3><p>A <strong>Content Delivery Network (CDN)</strong> is a globally distributed network of servers that stores copies of your static files (images, videos, CSS, JS). When a user accesses your site, the CDN delivers the content from the server closest to them, drastically reducing load times.</p><h4>Main Benefits:</h4><ul><li><strong>Speed</strong>: reduces latency by serving content from the nearest node.</li><li><strong>Scalability</strong>: handles traffic spikes without stressing the main server.</li><li><strong>Reliability</strong>: if one server goes offline, another one takes over.</li><li><strong>Security</strong>: many CDNs provide DDoS protection and firewalls.</li></ul><h3>Practical Example with Angular</h3><h4>Developing the Angular App</h4><p>Let’s say we have a simple Angular app that we want to distribute through a CDN.</p><pre>ng new cnd-angular-app --routing --standalone --style=scss --ssr=no --zoneless=yes<br>cd cnd-angular-app</pre><p>build the application:</p><pre>ng build</pre><h4>Pubblicazione su cloudfare</h4><p>You need to go to <a href="https://dash.cloudflare.com/">https://dash.cloudflare.com/</a> and create a new account.<br> Then, go to the menu in the top-right corner:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CVObraiWD4DUwAlC60LSdQ.png" /><figcaption>Cloudfare — Toolbar</figcaption></figure><p>select “Use direct upload”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5yFCjbnPS57QGEmJcpg0lg.png" /><figcaption>Cloudfare — Upload dist folder</figcaption></figure><p>Enter the project name and upload the folder <em>dist/cnd-angular-app/browser.</em></p><p>Once completed, you will see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O9LYZq6wpB_nQ0nCZYu7Dg.png" /><figcaption>Cloudfare — Project deployed</figcaption></figure><p>Cloudflare immediately serves your Angular app via CDN.<br>You don’t need to configure anything: global distribution is automatic.</p><h3>Can we expose only our application?</h3><h4>Using it for assets</h4><p>No: a CDN is not only for distributing the application, but it can also be used to manage <strong>assets</strong>.</p><p>For example, we can upload images in different sizes and serve them directly from a CDN, configuring Angular to point to the correct URLs.</p><p>This approach offers two advantages:</p><ul><li><strong>Deployment separation:</strong> we can deploy the app and assets at different times, reducing release time.</li><li><strong>Optimization:</strong> assets, which often don’t change frequently, can be updated and invalidated independently of the application.</li></ul><h3>Using it with third-party libraries</h3><p>Another use case is including common libraries via CDN, adopting the strategy called <strong>externals</strong>.</p><p>In this scenario, we don’t want Angular to include these libraries in the bundle: we prefer to load them <strong>directly from a CDN</strong> to lighten the build.</p><p>A typical flow, for example for Lodash:</p><p>Install only the <strong>types</strong> of the library as devDependencies (so Angular knows the API at compile time).</p><pre>npm install --save-dev @types/lodash</pre><p>Add a link to the library hosted on a CDN in your index.html:</p><pre>&lt;script src=&quot;https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js&quot;&gt;&lt;/script&gt;</pre><p>Create a file src/typings.d.ts to declare the global library:</p><pre>declare var _: any;</pre><p>At this point, we can use it in our Angular code:</p><pre>import { Component, OnInit } from &#39;@angular/core&#39;;<br><br>@Component({<br>  selector: &#39;app-root&#39;,<br>  template: `&lt;h1&gt;{{ message }}&lt;/h1&gt;`<br>})<br>export class AppComponent implements OnInit {<br>  message = &#39;&#39;;<br><br>  ngOnInit() {<br>    this.message = _.join([&#39;Like this post&#39;, &#39;if you enjoyed it!&#39;], &#39; &#39;);<br>  }<br>}</pre><p>With this approach:</p><ul><li>The app bundle is lighter,</li><li>Build times are reduced,</li><li>And if the library is widely used (e.g., Lodash, Bootstrap), it’s likely already cached in the user’s browser.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f7fcee27a52" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Really Happens When You Load a Web Page?]]></title>
            <link>https://medium.com/@golia.simone/what-really-happens-when-you-load-a-web-page-994d2bcb0ee7?source=rss-e0df3230de40------2</link>
            <guid isPermaLink="false">https://medium.com/p/994d2bcb0ee7</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[browsers]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Golia Simone]]></dc:creator>
            <pubDate>Sat, 19 Jul 2025 16:06:48 GMT</pubDate>
            <atom:updated>2025-07-19T16:07:41.639Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LEJpu7Z3MSgqztpTq1tipQ.png" /></figure><p>What are the steps that lead to the display of an HTML page in the browser? After an HTTP request is made, what really happens?</p><p>Understanding this process in depth helps us optimize web page performance by minimizing costly operations like reflow and repaint.</p><p>In this guide, we analyze the 7 fundamental steps that lead to the display of a web page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*r5Y0hB7R0J-ekXP8EJUNfQ.png" /></figure><h3>Receiving the HTML</h3><p>After the HTTP request is completed:</p><ul><li>The browser receives an <strong>HTML byte stream</strong> and decodes it (e.g., UTF-8).</li><li>The parsing of HTML occurs <strong>incrementally</strong> as data arrives.</li></ul><h4><strong>Best Practices</strong>:</h4><ul><li>Minimize HTML (remove spaces, unnecessary comments).</li><li>Use GZIP or Brotli compression on the server side.</li><li>Prefer HTTP/2 or HTTP/3 to reduce latency.</li><li>HTML streaming is already the default behavior.</li><li>Reduce TTFB (Time To First Byte) by avoiding server-side bottlenecks.</li></ul><h3>Parsing HTML to DOM Tree</h3><p>The HTML parser reads characters and converts them into <strong>tokens</strong> (e.g., &lt;div&gt;, &lt;p&gt;, comments, text).</p><p>1. Tokens are transformed into <strong>DOM nodes</strong>.</p><p>2. The <strong>DOM Tree</strong> (Document Object Model) is constructed, representing the structure of the page.</p><p>During parsing:</p><p><strong>&lt;script&gt; </strong>tags can block parsing:</p><ul><li>Inline and without async/defer: block;</li><li>With defer: executed after parsing;</li><li>With async: executed as soon as available;</li><li>With async: executed as soon as available;</li></ul><p><strong>&lt;link rel=”stylesheet”&gt;</strong> tags are <strong>blocking</strong> for layout.</p><h4>Parsing Example</h4><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;Demo&lt;/title&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;h1&gt;Hello!&lt;/h1&gt;<br>    &lt;p&gt;Welcome to a &lt;strong&gt;beautiful&lt;/strong&gt; web page.&lt;/p&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>Converted to tokens:</p><pre>[DOCTYPE]<br>[StartTag: html]<br>[StartTag: head]<br>[StartTag: title]<br>[Text: &quot;Demo&quot;]<br>[EndTag: title]<br>[EndTag: head]<br>[StartTag: body]<br>[StartTag: h1]<br>[Text: &quot;Hello!&quot;]<br>[EndTag: h1]<br>[StartTag: p]<br>[Text: &quot;Welcome to a web page &quot;]<br>[StartTag: strong]<br>[Text: &quot;beautiful&quot;]<br>[EndTag: strong]<br>[Text: &quot;.&quot;]<br>[EndTag: p]<br>[EndTag: body]<br>[EndTag: html]</pre><p><strong>Best Practices</strong></p><ul><li>Use defer for scripts:</li></ul><pre>&lt;script src=&quot;main.js&quot; defer&gt;&lt;/script&gt;</pre><ul><li>Avoid blocking inline scripts;</li><li>Maintain a well-formed and minimally nested HTML structure;</li><li>Use consistent semantic tags.</li></ul><h3>Parsing CSS to CSSOM Tree</h3><p>The browser constructs the <strong>CSSOM Tree</strong> (CSS Object Model) from:</p><ul><li>External CSS files (&lt;link rel=”stylesheet”&gt;)</li><li>Inline <strong>&lt;style&gt;</strong> blocks</li></ul><p><strong>CSS Example:</strong></p><pre>body {<br>  background-color: red;<br>}<br>h1 {<br>  color: blue;<br>  background-color: red;<br>}</pre><p>It is transformed into a data structure similar to:</p><pre>CSSStyleSheet<br>├── CSSRule (selector: body)<br>│   └── background-color: red<br>└── CSSRule (selector: h1)<br>    ├── color: blue<br>    └── background-color: red</pre><p>Each CSSRule is an object in memory that has:</p><ul><li>a selector (body, h1)</li><li>a list of properties (key-value)</li></ul><p>In this case, care must be taken because HTML rendering is blocked until external CSS is fully downloaded and parsed.<br>The browser cannot calculate styles and therefore cannot build the render tree without knowing how the elements appear.<br>This is why it is a best practice to place &lt;link rel=&quot;stylesheet&quot;&gt; in the &lt;head&gt;, but &lt;script&gt; at the end of the &lt;body&gt; (or use defer when possible).</p><h4>Best Practices</h4><ul><li>Place stylesheets in the &lt;head&gt;;</li><li>Minimize and combine CSS files;</li><li>Avoid @import, prefer &lt;link&gt;;</li><li>Use media for conditional loads:</li></ul><pre>&lt;link rel=&quot;stylesheet&quot; href=&quot;print.css&quot; media=&quot;print&quot;&gt;</pre><h3>(DOM + CSSOM) to Render Tree</h3><p>The <strong>Render Tree</strong> is an internal structure of the browser that represents what needs to be drawn on the screen, with calculated styles, sizes, and positions.</p><p>But it is neither the DOM nor the CSSOM: it is a filtered and styled representation of the visible elements.</p><p>Content of the Render Tree:</p><ul><li>Contains only visible elements (excludes &lt;head&gt;, &lt;script&gt;, elements with display: none)</li><li>Each node of the render tree has computed style information;</li><li>Elements outside the viewport are excluded (in some cases, in lazy optimizations).</li></ul><p>Each node of the Render Tree (e.g., RenderBox, RenderInline, etc.) contains:</p><ul><li>Reference to the DOM node;</li><li>Computed style (e.g., color, margin, font-size);</li><li>Box model (width, height, padding, border, margin);</li><li>Calculated position (x, y);</li><li>Z-index / stacking context;</li><li>Layer or non-layer (for compositing).</li></ul><h4>Example of Render Tree</h4><p><strong>HTML:</strong></p><pre>&lt;body&gt;<br>  &lt;h1&gt;Ciao&lt;/h1&gt;<br>  &lt;p style=&quot;color: red; display: none;&quot;&gt;Nascosto&lt;/p&gt;<br>  &lt;p class=&quot;grassetto&quot;&gt;Visibile&lt;/p&gt;<br>&lt;/body&gt;</pre><p><strong>CSS:</strong></p><pre>.grassetto {<br>  font-weight: bold;<br>}</pre><p><strong>DOM:</strong></p><pre>Document<br>└── body<br>    ├── h1<br>    │   └── &quot;Ciao&quot;<br>    ├── p (style: display: none)<br>    │   └── &quot;Nascosto&quot;<br>    └── p (class=&quot;grassetto&quot;)<br>        └── &quot;Visibile&quot;</pre><p><strong>CSSDOM:</strong></p><pre>CSSRule (Selector: .grassetto)<br>└── font-weight: bold</pre><p><strong>Render Tree:</strong></p><pre>RenderRoot<br>└── RenderBox (tag: h1)<br>    └── Text: &quot;Ciao&quot; (style: inherited/default)<br>└── RenderBox (tag: p.grassetto)<br>    └── Text: &quot;Visibile&quot; (style: font-weight: bold)</pre><p>We can notice that the &lt;p&gt; tag with display: none does not appear in the Render Tree.</p><h4>Useful Tips:</h4><ul><li>Avoid display: none on too many nested elements → the browser still analyzes them;</li><li>Use visibility: hidden if you want to avoid removing a node from the render tree (it does not hide it completely);</li><li>Avoid overly complicated dynamic styles (e.g., continuous CSS changes in JS);</li><li>Avoid unnecessary hidden elements (e.g., preloaded modals all at once).</li></ul><h3>Layout (Reflow)</h3><p>Up to this phase, what and how to display has been calculated, while in this phase, the focus is on where to position it and with what size.</p><p>In this phase, the browser calculates:</p><ul><li>The dimensions (width, height)</li><li>The positions (x, y) of each visible element in the viewport</li><li>The algorithm takes into account box model, flexbox, grid, etc.</li></ul><h3>What are the steps?</h3><ul><li>It starts from the root of the Render Tree (e.g., &lt;html&gt; → &lt;body&gt;)</li><li>Calculates the dimensions of each box:</li><li>width, height</li><li>margin, padding, border</li><li>Determines the <strong>relative</strong> and <strong>absolute</strong> position of each element</li><li>Takes into account:<br>- <strong>Layout model</strong>: block, inline, flex, grid, absolute, etc.<br>- <strong>Computed styles</strong> (from CSSOM);<br>- <strong>Internal content</strong> (e.g., if a div has width: auto, it is calculated based on its children)</li><li>Propagates the information to the children recursively</li></ul><p>This is the most “expensive” phase because some DOM or CSS changes can cause <strong>reflow</strong>, meaning the entire layout needs to be recalculated.</p><p>Optimizing the layout is essential for a smooth user experience, especially on mobile devices or with animations.</p><h4>Useful Tips:</h4><ul><li>Do not read offsetHeight, clientWidth, etc. immediately after DOM changes (they force synchronous layout);</li><li>Group multiple DOM changes in a requestAnimationFrame;</li><li>Use display: flex and grid responsibly (avoid deep nesting);</li><li>Avoid complex table layout: it is expensive to calculate;</li><li>Use contain: layout or contain: size to isolate reflow;</li></ul><h3>Painting</h3><p>Painting is the phase in which the browser translates the nodes of the Render Tree into pixels (or graphic commands), meaning it turns visual elements into instructions to be drawn on the screen:</p><ul><li>Background colors</li><li>Borders, text, shadows</li><li>Images and multimedia content</li></ul><p>Each “paint operation” is tracked in separate layers.</p><h3>What happens exactly during Painting?</h3><p>For each node of the render tree:</p><ol><li>The browser generates a list of drawing instructions (called <em>display list</em> or <em>paint commands</em>)</li><li>These instructions describe:</li></ol><ul><li>Background colors (background-color)</li><li>Text (color, font, text-decoration)</li><li>Borders, shadows (box-shadow)</li><li>Images (background-image, &lt;img&gt;)</li><li>SVG, canvas, video</li></ul><ol><li>Each “paintable” is transformed into a series of rectangles, lines, paths, bitmaps.</li><li>The result is stored in rasterized layers.</li></ol><h3>When does a repaint occur (without reflow)?</h3><p>A repaint is a new painting phase without any change to the layout structure.</p><pre>element.style.backgroundColor = &quot;red&quot;; <br>element.style.visibility = &quot;hidden&quot;;   <br>element.style.color = &quot;green&quot;;</pre><p>Repaints are less expensive than reflows, but if they occur frequently (e.g., due to poorly managed animations), they still degrade performance.</p><h4>Useful Tips:</h4><ul><li>Avoid frequent changes to color, background, border, box-shadow, etc. on large areas;</li><li>Prefer opacity or transform for animations, not top, left, width;</li><li>Use will-change only when necessary to avoid unnecessary promotions;</li><li>Minimize heavy shadows, filters, blurs → they are expensive to paint;</li><li>Do not overuse text-shadow, backdrop-filter, filter.</li></ul><h3>Compositing</h3><p>Compositing is the phase in which the browser combines (composes) all the graphic layers into a single final image to be displayed on the screen.</p><p>The layers are then ordered and composed to create the final scene:</p><ul><li>The browser divides the page into compositing layers.<br>- Some layers are painted separately (e.g., elements with transform, opacity, position: fixed, will-change)</li><li>Each layer is rasterized (converted into a bitmap)</li><li>The layers are ordered according to the stacking context (z-index, opacity, position, etc.)</li><li>The compositor thread (separate from the main thread) combines them, applying:<br>- Transformations (translate, scale, rotate);<br>- Opacity (opacity)<br>- Clipping (cropping).</li><li>The result is sent to the GPU and displayed on the screen</li></ul><p>If there is a scroll or an animation, the browser can use partial compositing (only the affected layers).</p><h4>Compositing is efficient because:</h4><ul><li>It can occur in the compositor thread, separate from the main JS thread</li><li>It can use the GPU for accelerated graphic operations</li><li>It allows for smooth animations without forcing reflow or repaint</li></ul><p>Be careful not to create too many compositing layers:</p><ul><li>You increase GPU memory usage</li><li>You make the compositor’s job more difficult</li><li>You risk degrading performance</li></ul><h4>Useful Tips:</h4><ul><li>Use transform, opacity for “GPU-friendly” animations;</li><li>Do not overuse will-change: each layer occupies GPU memory;</li><li>Avoid unnecessary multiple promotions (e.g., every element in a list with will-change);</li><li>Reduce unnecessary stacking contexts (z-index, position: relative) where they are not needed;</li><li>Use DevTools to check the active layers (Rendering tab → “Layer borders”).</li></ul><h3>Display</h3><p>Finally, the resulting image is sent to the GPU (hardware acceleration) and drawn on the screen.</p><p>The cycle can repeat many times per second (e.g., 60fps) if there are animations.</p><p>Thank you for taking the time to read! I hope that this information has been useful and inspiring to you.</p><p>I would love to hear about your experience with this topic: do you have any suggestions or ideas to share? Your opinion is important and could enrich the discussion!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=994d2bcb0ee7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inside Angular: How the Ivy Compiler Works (and Why You Should Care)]]></title>
            <link>https://medium.com/@golia.simone/inside-angular-how-the-ivy-compiler-works-and-why-you-should-care-e3ea9262023a?source=rss-e0df3230de40------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3ea9262023a</guid>
            <category><![CDATA[angular-ivy]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Golia Simone]]></dc:creator>
            <pubDate>Sun, 13 Jul 2025 20:23:02 GMT</pubDate>
            <atom:updated>2025-07-13T20:23:02.607Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*isx8K2OZitBJYuXMo8kuzA.png" /></figure><p>Angular is more than just a framework . It’s a finely tuned machine that compiles, optimizes, and manages the DOM like few other web environments. In this post, we’ll explore one of its most fascinating aspects: <strong>the internal functions of the Ivy compiler</strong>.</p><p>We’ll uncover what really happens when you use something as simple as @if, exploring how templates are transformed behind the scenes. You&#39;ll see a small, clear example to illustrate this process, and discover why understanding the internal functions, those starting with ɵɵ is so valuable. With this approach, you&#39;ll be able to analyze and understand even more complex template scenarios.</p><h4>A New Syntax in Angular Templates</h4><p>Angular introduces a syntax reminiscent of programming languages, but used <strong>directly in templates</strong>, in a <strong>block-based</strong> structure:</p><h4>Basic Example</h4><pre>@if (user.isLoggedIn) {<br>  &lt;p&gt;Welcome, Simone!&lt;/p&gt;<br>} @else {<br>  &lt;p&gt;Please log in&lt;/p&gt;<br>}</pre><h4>How Is This Code Transformed?</h4><p>Angular converts this syntax into a <strong>stateless and performant model</strong>, translating it into <strong>DOM rendering instructions</strong>. The example above is converted into something like this:</p><pre>ɵɵtemplate(0, ifTrueTemplate, 1, 0);<br>ɵɵtemplate(1, elseTemplate, 1, 0);<br><br>function ifTrueTemplate(rf, ctx) {<br>  if (rf &amp; 1) {<br>    ɵɵelementStart(0, &#39;p&#39;);<br>    ɵɵtext(1, &#39;Welcome, Simone!&#39;);<br>    ɵɵelementEnd();<br>  }<br>}<br><br>function elseTemplate(rf, ctx) {<br>  if (rf &amp; 1) {<br>    ɵɵelementStart(0, &#39;p&#39;);<br>    ɵɵtext(1, &#39;Please log in&#39;);<br>    ɵɵelementEnd();<br>  }<br>}</pre><p>Angular uses these functions to create, update, or destroy parts of the DOM dynamically, <strong>without recreating the entire structure</strong>, as the old <strong>*ngIf</strong> did.</p><h4>What Are `ɵɵ` Functions?</h4><p>Functions starting with `ɵɵ` (pronounced ‘<strong><em>ivy ivy’</em></strong>) are <strong>internal APIs of the Ivy runtime</strong>, the rendering engine used by Angular since version 9. <br>These are <strong>automatically generated by the AOT compiler</strong> during template compilation.</p><h4>What Are They For?</h4><ul><li><strong>High performance</strong>, thanks to an optimized abstract DOM;</li><li><strong>Smaller bundle size</strong>, avoiding runtime parsing and enabling tree-shaking;</li><li><strong>Complete control over DOM rendering and updates.</strong></li></ul><h4>Some Examples</h4><pre>| Category               | Function                          | Description |<br>|------------------------|-----------------------------------|----------------------------------------|<br>| **DOM Creation**       | `ɵɵelementStart`, `ɵɵelementEnd`  | Creates and closes HTML elements       |<br>|                        | `ɵɵtext`                          | Creates static text nodes              |<br>| **Interpolation**      | `ɵɵtextInterpolate` and variants  | Inserts dynamic content                |<br>| **Binding**            | `ɵɵproperty`, `ɵɵstyleProp`, etc. | Handles dynamic props and styles       |<br>| **Logic Control**      | `ɵɵtemplate`, `ɵɵcontainer`       | Conditional blocks and loops           |<br>| **Components**         | `ɵɵcomponentHostSyntheticListener`| Handles component events               |<br>| **Pipes**              | `ɵɵpipe`, `ɵɵpipeBind1`           | Executes pipes in the template         |<br>| **Events**             | `ɵɵlistener`                      | Registers listeners (e.g. click)       |<br>| **Content Projection** | `ɵɵprojection`                    | Manages `&lt;ng-content&gt;`                 |<br>| **Injection**          | `ɵɵinject`, `ɵɵviewQuery`         | Injects services or queries components |</pre><h4>Practical Example: Component Compilation</h4><p>Let’s create a new Angular project:</p><pre>npx @angular/cli@latest new example-ivy</pre><p>Modify `app.ts`:</p><pre>import { Component, signal } from &#39;@angular/core&#39;;<br><br>@Component({<br>  selector: &#39;app-root&#39;,<br>  template: `&lt;h1&gt;Hello {{ name() }}!&lt;/h1&gt;`<br>})<br>export class App {<br>  name = signal(&#39;Simone&#39;);<br>}</pre><h4>What Does Angular Generate?</h4><p>The template is transformed into an internal structure like this:</p><pre>App.ɵcmp = ɵɵdefineComponent({<br>  type: App,<br>  selectors: [[&#39;app-root&#39;]],<br>  decls: 2,<br>  vars: 1,<br>  template: function(rf, ctx) {<br>    if (rf &amp; 1) {<br>      ɵɵelementStart(0, &quot;h1&quot;);<br>      ɵɵtext(1);<br>      ɵɵelementEnd();<br>    }<br>    if (rf &amp; 2) {<br>      ɵɵadvance();<br>      ɵɵtextInterpolate(&quot;Hello &quot;, ctx.name(), &quot;!&quot;);<br>    }<br>  },<br>  encapsulation: 2<br>});</pre><h4>What Can We Find in the Compiled Code?</h4><p>Build the project:</p><pre>npm run build</pre><p>Open the file like `<em>./dist/example-ivy/browser/main-*.js</em>`. You’ll see something like this:</p><pre>var bi = class e {<br>    name = Un(&quot;Simone&quot;);<br>    static ɵfac = function(n) { return new(n || e) };<br>    static ɵcmp = Xn({<br>        type: e,<br>        selectors: [[&quot;app-root&quot;]],<br>        decls: 2,<br>        vars: 1,<br>        template: function(n, r) {<br>            n &amp; 1 &amp;&amp; (Yo(0, &quot;h1&quot;), Fa(1), Ko());<br>            n &amp; 2 &amp;&amp; (Ca(), Jo(&quot;Hello &quot;, r.name(), &quot;!&quot;));<br>        },<br>        encapsulation: 2<br>    })<br>};</pre><p>The names `<em>Yo</em>`, `<em>Fa</em>`, `<em>Jo</em>` are minified versions of `<em>ɵɵ</em>` functions:</p><pre>| Minified | Real Function         | Purpose                            |<br>|----------|-----------------------|------------------------------------|<br>| `Yo`     | `ɵɵelementStart`      | Opens an element                   |<br>| `Fa`     | `ɵɵtext`              | Static text node                   |<br>| `Ko`     | `ɵɵelementEnd`        | Closes element                     |<br>| `Ca`     | `ɵɵadvance`           | Moves internal rendering cursor    |<br>| `Jo`     | `ɵɵtextInterpolate`   | Interpolates dynamic text          |</pre><p>You can analyze the output using online tools like <a href="https://beautifier.io/">Beautifier</a>.</p><h3>Why Should You Care About These Functions?</h3><h4>Improve Debugging</h4><p>Knowing how Angular works under the hood helps you:</p><ul><li>Understand <strong><em>why</em></strong> something isn’t updating;</li><li>Read minified code in `.js/.mjs`;</li><li>Spot change detection issues;</li><li>Avoid memory leaks and unpredictable rendering.</li></ul><h4>Final Thoughts</h4><p>Understanding Ivy’s internals isn’t just for framework contributors — it’s <strong>a superpower</strong> for developers building complex, scalable Angular applications.</p><p>Knowing how `ɵɵ` functions work and how components are compiled gives you more control over:</p><ul><li><strong>ChangeDetectionStrategy;</strong></li><li><strong>Signals and computed;</strong></li><li><strong>Rendering performance.</strong></li></ul><p>The more you understand Angular, the more Angular works *for you* (and not the other way around).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3ea9262023a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>