<?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 David Nanyan on Medium]]></title>
        <description><![CDATA[Stories by David Nanyan on Medium]]></description>
        <link>https://medium.com/@dave_go?source=rss-184dd19e226f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4e61fgxXDx3yDhG4s6CXzw.jpeg</url>
            <title>Stories by David Nanyan on Medium</title>
            <link>https://medium.com/@dave_go?source=rss-184dd19e226f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 03:35:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dave_go/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[Understanding CSP Errors Caused by Cloudflare’s Page Shield: “Refused to Execute Inline Script…]]></title>
            <link>https://medium.com/@dave_go/understanding-csp-errors-caused-by-cloudflares-page-shield-refused-to-execute-inline-script-211bdbc99af5?source=rss-184dd19e226f------2</link>
            <guid isPermaLink="false">https://medium.com/p/211bdbc99af5</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[content-security-policy]]></category>
            <category><![CDATA[cloudflare]]></category>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[error]]></category>
            <dc:creator><![CDATA[David Nanyan]]></dc:creator>
            <pubDate>Sun, 27 Oct 2024 20:52:26 GMT</pubDate>
            <atom:updated>2024-10-27T20:55:30.351Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding CSP Errors Caused by Cloudflare’s Page Shield: “Refused to Execute Inline Script Because It Violates…”</h3><p>If you’ve recently encountered an errors like this in your logs:</p><pre>[Report Only] Refused to execute inline script because it violates <br>the following Content Security Policy directive: &quot;script-src &#39;none&#39;&quot;. <br>Either the &#39;unsafe-inline&#39; keyword, a hash (&#39;sha256-EA/3ywQq8zmQJAJwVLTRDR7mL58FWAx/vxnPLVEGXYU=&#39;), or a nonce (&#39;nonce-...&#39;) is required to enable inline execution.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ntSIIdhja5PPa5Ax-5zadw.png" /></figure><p>it’s a message that can appear confusing at first glance. This error might not directly impact your website’s functionality, but understanding it and knowing how to manage it can still be valuable.</p><h3>The Cause: Cloudflare’s Page Shield Adding a Report-Only Header</h3><p>This warning message is often the result of Cloudflare’s <strong>Page Shield</strong> feature, which periodically adds a Content-Security-Policy-Report-Only header to your site’s responses. Here’s what this header might look like:</p><pre>Content-Security-Policy-Report-Only: script-src &#39;none&#39;; report-uri https://csp-reporting.cloudflare.com/cdn-cgi/script_monitor/report?...</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6hE3SgX0PvKR1qct-ba6Tg.png" /></figure><p>Have you noticed the phrase script-src &#39;none&#39; in that Content-Security-Policy-Report-Only header? <br>Well, here’s what’s going on. The script-src &#39;none&#39; directive is part of a Content Security Policy (CSP) designed to control what kinds of scripts can run on your site. By setting script-src &#39;none&#39;, the policy effectively disallows all scripts from running—no inline JavaScript, no external scripts, nothing.</p><p>In Cloudflare’s case, this directive shows up in a <strong>report-only</strong> CSP header, meaning it won’t actually block any scripts on the website. Instead, every script will be logged and sent to Cloudflare’s reporting system for analysis, letting Cloudflare collect data on which scripts are running on your site without stopping them from executing. This way, they can monitor for potential security issues while keeping your site’s functionality intact.</p><h3>How to Manage (or Ignore) These Warnings</h3><p>If you’d like to reduce the noise in your logs or get rid of the CSP report-only header altogether, here are a few ways to do it:</p><ol><li><strong>Modify Cloudflare Page Shield Settings</strong><br>Go to your Cloudflare dashboard and look for the Page Shield settings. If you don’t need Cloudflare to monitor inline scripts this way, you may be able to turn off or adjust the reporting settings. This will stop the Content-Security-Policy-Report-Only headers from being added, cleaning up your logs without affecting security.</li><li><strong>Filter Out the Report-Only Messages in Your Logs</strong><br>If disabling Page Shield isn’t an option (or you’d prefer to keep the added layer of monitoring), you can set up filters to ignore specific Cloudflare report-only errors. Many logging systems allow you to filter out these messages so they won’t clutter your logs, letting you focus on more critical issues.</li></ol><h3>Resources</h3><p>If you’re dealing with Content Security Policies or want to dive deeper into how Cloudflare’s Page Shield works, here are some valuable resources:</p><ul><li><a href="https://developers.cloudflare.com/page-shield/how-it-works/">https://developers.cloudflare.com/page-shield/how-it-works/</a></li><li><a href="https://blog.cloudflare.com/page-shield-generally-available/">https://blog.cloudflare.com/page-shield-generally-available/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=211bdbc99af5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing Text Truncation: Effective Strategies]]></title>
            <link>https://medium.com/@dave_go/testing-text-truncation-effective-strategies-2a589841a22b?source=rss-184dd19e226f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a589841a22b</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[cypress]]></category>
            <dc:creator><![CDATA[David Nanyan]]></dc:creator>
            <pubDate>Sun, 03 Sep 2023 22:38:48 GMT</pubDate>
            <atom:updated>2023-09-03T22:40:40.520Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lvJO0qgOMeZsw8F_YWrS7w.png" /></figure><p>I think many developers have encountered issues with broken UI layouts caused by unexpectedly long text elements on the frontend. <br>When text content exceeds the available space, truncation techniques like CSS’s text-overflowor JavaScript functions need to be applied.</p><p>Ensuring that these truncations work flawlessly across various scenarios requires effective testing strategies. In this article, we will delve into approaches for testing UI components that involve truncation, whether achieved through CSS (text-overflow) or JavaScript functions.</p><h3>Truncation Implemented with JavaScript</h3><p>When utilizing JavaScript for truncating text, either through libraries like the popular <a href="https://lodash.com/docs/4.17.15#truncate">lodash</a> _.truncate function or custom implementations, testing becomes relatively straightforward. We can write unit tests to cover the different scenarios we expect to encounter.</p><p>For instance, when using a custom truncation function, a simple test could involve verifying the return value:</p><pre>import { truncate } from &#39;./custom-truncation.js&#39;;<br><br>it(&quot;truncates the text&quot;) {<br> expect(truncate(&quot;your long text&quot;, 10)).toEqual(&quot;expected&quot;)<br>}</pre><p>In scenarios involving libraries, it might be worthwhile to test the truncation within the component itself. For instance, in a React component:</p><pre>import { render, screen } from &#39;@testing-library/react&#39;<br><br>it(&#39;should render menu with truncated header&#39;, () =&gt; {<br> render(&lt;Menu {…props} /&gt;)<br><br> const header = screen.getByRole(&#39;header&#39;)<br><br> expect(title).toHaveTextContent(&#39;This is some looong title too long…&#39;)<br>})</pre><p>Component-level testing provides a more direct insight into how the truncation behaves in the context of your UI.</p><h3>Handling Truncation through CSS</h3><p>However, things become more intricate when dealing with truncation accomplished via CSS properties like text-overflow: ellipsis. The initial instinct might be to write tests similar to those above — render the component and inspect the text content. But, unfortunately, this approach will not yield accurate results.</p><p>Due to the nature of text-overflow truncation, the entire text remains within the HTML element, causing assertions to fail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0aShqW2jzTnV1gY5bkeHvg.png" /></figure><p>Link to the <a href="https://codepen.io/davefres/pen/MWZjYOz">pen</a>.</p><p>So, how do we effectively test CSS-based truncation?</p><p>To confirm successful truncation via text-overflow, we can implement a simple validation technique by comparing offsetWidthand scrollWidth:</p><pre>function isEllipsisActive(e: HTMLElement) {<br> return (e.offsetWidth &lt; e.scrollWidth);<br>}</pre><p>(For a quick refresher on offsetWidth and scrollWidth, refer to this <a href="https://stackoverflow.com/a/21064102">explanation</a>).</p><p>However, there’s a catch. If your testing library relies on jsdom, accessing offsetWidth and scrollWidth directly from an element might not work due to rendering limitations. This limitation is further elaborated upon <a href="https://github.com/testing-library/react-testing-library/issues/353#issuecomment-618364310">here</a>.</p><p>Nonetheless, if you’re using a library like Cypress, which performs actual rendering, you can incorporate this validation into your test:</p><pre>it(&quot;should render menu with truncated header&quot;, () =&gt; {<br> cy.visit(&quot;your_page_url&quot;); // Replace with the URL of the page containing the element<br> <br> cy.get(&#39;[data-testid=&quot;your_element_id&quot;]&#39;).then(($element) =&gt; {<br>   const offsetWidth = $element[0].offsetWidth;<br>   const scrollWidth = $element[0].scrollWidth;<br>   expect(offsetWidth).to.be.lessThan(scrollWidth);<br> });<br>});</pre><p>But what if your only option is a library that relies on jsdom, and accessing params such as offsetWidth is not feasible?</p><p>In that case, an alternative approach involves validating the existence of specific styles applied to the HTML element:</p><pre>it(&#39;should render menu with truncated header&#39;, () =&gt; {<br>  // selection of element<br>  // ...<br><br>  expect(element).toHaveStyle(&#39;text-overflow: ellipsis&#39;);<br>  expect(element).toHaveStyle(&#39;overflow: hidden&#39;);<br>  expect(element).toHaveStyle(&#39;white-space: nowrap&#39;);<br>});</pre><p>While not as robust as testing the actual rendered value, this method can still serve as a viable solution in certain scenarios.</p><h3>Results</h3><ul><li><strong>JavaScript Truncation:</strong><br> * Write unit tests covering your truncation function<br> * Write component tests checking the actual text inside DOM after truncation</li><li><strong>CSS Truncation:</strong><br>* Verify truncation using rendering libraries like Cypress, comparing offsetWidth and scrollWidth<br> * For jsdom-based libraries ensure expected CSS properties are present</li></ul><p>By following these steps, we can ensure consistent and reliable truncation behavior.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a589841a22b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 quick steps to improve the performance of your website]]></title>
            <link>https://medium.com/@dave_go/5-quick-steps-to-improve-the-performance-of-your-website-c760c6b5650a?source=rss-184dd19e226f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c760c6b5650a</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[gzip]]></category>
            <category><![CDATA[caching]]></category>
            <category><![CDATA[web-performance]]></category>
            <dc:creator><![CDATA[David Nanyan]]></dc:creator>
            <pubDate>Tue, 06 Sep 2022 18:52:42 GMT</pubDate>
            <atom:updated>2022-12-15T10:44:43.273Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FDV73oZboI5hoRymjkt-Yg.jpeg" /></figure><p>Have you come across a project/website that you haven’t bothered to optimize much and you need to speed it up in a short time?<br>Then this article might help you!</p><p>There are a lot of techniques and patterns to speed up the work of a web application, but in this article I will consider the methods that seemed to me personally the most effective, fast and easy to implement.</p><p><strong>TL;DR</strong></p><p>1. Optimize media<br>2. Compress text files<br>3. Cache static files<br>4. Use code splitting<br>5. Eliminate render-blocking resources</p><h3>1. Optimize media</h3><p>Media files are often one of the largest files downloaded by the browser, so their optimization can significantly speed up the work of your website.</p><ul><li>Reduce your PNG’s, JPEG’s with services like <a href="https://tinypng.com/">TinyPNG</a> or similar ones</li><li>Resize your images based on size they would be displayed.</li></ul><figure><img alt="image with two div’s with different kitten img sizes" src="https://cdn-images-1.medium.com/max/1024/1*p-i6efxD2buNgAMmg7YAkw.png" /></figure><p>As we can see, the kitten on top and bottom look the same (cute). Therefore, there is no need to upload a 3700x3700px image if we have our image container significantly smaller in size. Thus we can shrink image to div size 400x400px and make load time 5 time faster and file size more than 1mb smaller.</p><ul><li>Display different images for different viewport sizes. If you have large background image that you don’t need on mobile, you can load smaller one or just set background color. For that you’re gonna need to use media queries.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb7abddf827a80b17fcab1ab6adb39f2/href">https://medium.com/media/fb7abddf827a80b17fcab1ab6adb39f2/href</a></iframe><p>Thanks to the media query, the browser will know that a large background needs to be loaded only at 1900px and more.</p><ul><li>Convert media to Webp, Webm and use them.</li></ul><p>When you use the WebP format, images are smaller in size, but they almost never compromise quality, allowing your page to load faster. <br>Most newer versions of browsers support webp/webm format. <br>And for older browsers you can always use other formats as fallbacks:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/061596df8799ed63ca5a84fbb3ff7af2/href">https://medium.com/media/061596df8799ed63ca5a84fbb3ff7af2/href</a></iframe><p>The only disadvantage is that you will have to store at least two image formats wich will cost you extra space. Most of the time that is not a problem.</p><ul><li>Remove image metadata (if you want to go crazy)</li></ul><p>On average, image metadata makes up 16% of a typical JPEG file on the web. It is used to store data describing information about image rights and administration. The metadata of the image can also be sent and used by AI’s.<br>So if you don’t care about copyright issues, AI and want go crazy — just cut down the metadata using tools like <a href="https://www.verexif.com/en/">verexif</a>.</p><h3>2. Compress (GZIP)</h3><p>When we use websites, we receive <strong>HTML</strong>, <strong>CSS</strong> and <strong>JS</strong> files from the server. These are all text files and they can be compressed.</p><p>If we send a gziped file to the browser instead of plain old index.html, we’d save on bandwidth and download time. The browser could download the gzipped file, extract it, and then show it to user much faster.</p><p><em>Ok, so how do we make our files gzipped?</em></p><p>The answer is we add on our server (backend) HTTP header Content-Encoding: gzip.</p><p>It works simple, if the browser supports any compression schemes, when executing a request, it adds a header Accept-Encoding: gzip, deflate, where <em>gzip</em> and <em>deflate</em> are two possible compression schemes.</p><p>If the server doesn’t send the <em>content-encoding</em> response header, it means the file is not compressed which is default behaviour on many servers.</p><p>So all we need to do is add on our server content-encoding header.</p><p>For example, in Go we need to wrap our handler like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42bb4d63005c536ab07425b0b36fa07f/href">https://medium.com/media/42bb4d63005c536ab07425b0b36fa07f/href</a></iframe><p>In Nodejs we could use compress library (be aware that you can configure what files/routes to compress):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff9252b0e9ab5bdea93c2e1102ff67f9/href">https://medium.com/media/ff9252b0e9ab5bdea93c2e1102ff67f9/href</a></iframe><p>Enabling compression is one of the fastest and more effective ways to improve website performance. So go for it and enjoy speed boost.</p><h3>3. Cache static files</h3><p>I would divide caching into two parts:</p><ul><li>Browser cache</li><li>Server side cache</li></ul><h4>Browser cache</h4><p>As we know browser caching improves and speeds up browsing. Once you’ve downloaded an asset, it lives (for a time) on your machine. Retrieving files from your hard drive will always be faster than retrieving them from a remote server, no matter how fast your connection is.</p><p>Because of that we should definitely use it for static assets like <strong>JavaScript</strong>, <strong>CSS</strong> and <strong>Images</strong>.</p><p><em>So what we need to set up browser cache?</em></p><p>Basically, for practical use we neeed only two HTTP headers! Simple, right?</p><p>Our HTTP header would be Cache-Control and Etag.</p><ul><li><strong><em>Cache-Control</em></strong>. The server can return a Cache-Control header to specify how, and for how long, the browser should cache the individual response.</li><li><strong><em>ETag</em></strong>. When the browser finds an expired cached response, it can send a small token (usually a hash of the file’s contents) to the server to check if the file has changed. If the server returns the same token, then the file is the same, and there’s no need to re-download it.</li></ul><blockquote>Note that you can use Expires instead of Cache-Control. But Cache-Control was introduced in HTTP/1.1 and offers more options than Expires.</blockquote><p>If you use Express.js then you good to go, because Express.js sets up headers for you. If you use pure Nodejs your code could look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/055b4575eec5fb1daf8579548aa9d299/href">https://medium.com/media/055b4575eec5fb1daf8579548aa9d299/href</a></iframe><p>In Go it could look like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/66b264fec6b0ce3e8f29245bddbbe823/href">https://medium.com/media/66b264fec6b0ce3e8f29245bddbbe823/href</a></iframe><p>The mechanism is the same in both languages, if there is a match between the <em>If-None-Match</em> field and the key you generate in the server, there is no need to rebuild the response again as the browser already has it. In that case set the HTTP status to StatusNotModified, i.e 304 and return.</p><h4>Server side cache</h4><p>If we have a complex and heavy page that takes a lot of time to generate the HTML output then our server will have a hard time. It’s certainly not useful to cache it on the browser, because if our page changes, the user won’t see the new content anytime soon and our server still would have to regenerate the page for each different user accessing our web application.<br>You can think about a large news portal, do they process their HTML over and over again for each visitor?</p><p>This is where server-side cache comes in handy.</p><p>The difficult part is to decide where you want to cache the page.</p><blockquote>Never cache <strong>POST</strong>, <strong>PUT</strong> or <strong>DELETE</strong> requests. These are used to change resources and not retrieve data, so it doesn’t make sense to cache it.</blockquote><ul><li>In-Memory: Use a part of RAM in the server as cache, thus it’s fastest cache you’ll ever have and the easiest to implement. In this case, the additional space needed to RAM for caching purpose. The drawback is that if you have multiple servers (which you should probably have), you’ll end with N copies of these cached content. If the process restarts for any reason, it’ll lose all the cached content and thus slowing down the first request again.</li><li>Centralized cache: For example Redis. It’s a high performance, assures data consistency and battle tested in-memory database widely used. It’s not as fast as process in-memory, because it requires network calls, but content is shared across all servers, so they are not duplicated and neither require resources from the application server.</li></ul><p>Basically it from code perspective it doesn’t matter where to store our cached data in redis or in-memory, because we will just set and get data from storage (if it’s redis or in memory cache).</p><p>So, Nodejs and Redis cache would look like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ef1f894c61647ab4e266bf960dac6bb/href">https://medium.com/media/0ef1f894c61647ab4e266bf960dac6bb/href</a></iframe><h3>4. Use code splitting</h3><p>When you load your website for the first time it’s going to load files like <strong>HTML</strong>, <strong>CSS</strong> and <strong>JS</strong>. It could happen that content that is not needed is downloaded, making the bundle file large with a long download time; this increases the website’s load time.</p><p>Another problem to consider is every time you change the content of a resource, for example release a new version of your JavaScript bundle, the browser needs to re-fetch it to get the new version in cache. That is slow.</p><p>Here is where code splitting comes into play.</p><p>If you instead split your bundle up to many smaller bundles with code splitting, and you change one of them, the others don’t need to be reloaded because they haven’t changed.</p><p>Great, right?</p><p>Code splitting could be achieved using any bundlers like Webpack, Browserify, Rollup, etc. For example, Webpack documentation tells us that there are three general approaches to code split available:</p><ul><li>Entry Points: Manually split code using entry configuration.</li><li>Prevent Duplication: Use Entry dependencies or SplitChunksPlugin to dedupe and split chunks.</li><li>Dynamic Imports: Split code via inline function calls within modules.</li></ul><p>Since our task is to speed up the website as quickly as possible, I suggest taking a closer look at the <em>dynamic imports</em>.<br>Using dynamic imports is quite simple.<br>Most libraries like React, Vue, Angular have a great documantation on how to do it.</p><p>For example in react we could make use of js dynamic import (looks exactly like pure js dynamic import):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb2324a6ff790d8fc04f9fff98920a25/href">https://medium.com/media/bb2324a6ff790d8fc04f9fff98920a25/href</a></iframe><p>or use build in methods in react library for components:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3b711e9236b5d6b59760a72130af7d3/href">https://medium.com/media/c3b711e9236b5d6b59760a72130af7d3/href</a></iframe><p>The example above is code splitting by routes. <br>Basically, you can decide to split anything and anywhere, but remember that main purpose is making first load of the website faster but at the same time not to disrupt the user experience.</p><p>And because deciding where to start splitting could be tricky I would personally suggest starting with routes (using dynamic imports). This is a safe choice because users are unlikely to be interacting with other elements on the page at the same time and they are used to waiting for a new route to load.</p><p>After that, you could split more and more using the rest of the methods.</p><h3>5. Eliminate render-blocking resources</h3><p><em>What is render-blocking resources?</em></p><p>Render-blocking resources are <strong>scripts</strong>, <strong>stylesheets</strong>, and <strong>HTML</strong> imports that block or delay the browser from rendering web page.</p><p>One of the most powerful techniques to eliminate render-blocking resources is deferring or delaying non-critical resources. The browser will spend less time loading resources that aren’t crucial for the user experience (images not in the viewport, CSS styling for non-critical content, etc.).</p><h4>For images:</h4><p>We can always lazy load images, that is not in viewport by lazy loading:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99bf32800eb549aadd8d91cdd09bbbd2/href">https://medium.com/media/99bf32800eb549aadd8d91cdd09bbbd2/href</a></iframe><h4>For CSS</h4><p>You may not use all of your CSS to render the critical part of your page (above-the-fold content, other pages CSS). <br>So you can split the CSS into critical and non-critical parts.<br>Actually, it is a performance optimization technique that has gained a lot of popularity since the introduction of Core Web Vitals as it also improves LCP scores.</p><p>You can defer CSS loading like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6e13c53a2696a5503e051f965b06633/href">https://medium.com/media/a6e13c53a2696a5503e051f965b06633/href</a></iframe><h4>For javascript scripts</h4><p>Once you’ve identified critical code, you can apply one of the two attributes to your non-critical script: defer or async. Defer tells the browser not to wait for the script while async loads in the background and runs when ready.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/60a37eaa5713c09230c74f6456860b02/href">https://medium.com/media/60a37eaa5713c09230c74f6456860b02/href</a></iframe><p>All of those techniques above aim at eliminating render-blocking resources and avoiding chaining critical requests.</p><h3>Conclusion</h3><p>Website optimization is actually an endless and very exciting process.<br>The 5 steps described above will help you to start optimizing and significantly speed up your slow website in a relatively short time.<br>The more you do, the harder it will be to speed up your site even more, but never despair and keep going.</p><p>In your process, I strongly recommend using:<br>- performance insight and lighthouse tabs in devtools<br>- “Even faster web sites” by Steve Souders<br>- this article ;)</p><figure><a href="https://www.buymeacoffee.com/davefres"><img alt="" src="https://cdn-images-1.medium.com/max/170/1*9vg3-OY14aZN1UpKwIxxZg.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c760c6b5650a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>