<?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 Sergey Antoninko on Medium]]></title>
        <description><![CDATA[Stories by Sergey Antoninko on Medium]]></description>
        <link>https://medium.com/@lyxsus?source=rss-15fb65c7869------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*GMtPZrnPJaZYqNWm.jpg</url>
            <title>Stories by Sergey Antoninko on Medium</title>
            <link>https://medium.com/@lyxsus?source=rss-15fb65c7869------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 12:08:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lyxsus/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[Fixing FART (Flash of inAccurate coloR Theme) for static websites]]></title>
            <link>https://medium.com/@lyxsus/fixing-fart-flash-of-inaccurate-color-theme-for-static-websites-7935f7f85e20?source=rss-15fb65c7869------2</link>
            <guid isPermaLink="false">https://medium.com/p/7935f7f85e20</guid>
            <category><![CDATA[themes]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[service-worker]]></category>
            <dc:creator><![CDATA[Sergey Antoninko]]></dc:creator>
            <pubDate>Sun, 09 May 2021 00:40:14 GMT</pubDate>
            <atom:updated>2021-05-09T00:40:14.309Z</atom:updated>
            <content:encoded><![CDATA[<p>While I have some free time, I’ve finally decided to start my deveveloper blog. The first problem, that I want to play with has a catchy name and was raised in <a href="https://css-tricks.com/flash-of-inaccurate-color-theme-fart/"><strong>Flash of inAccurate coloR Theme (FART)</strong></a> article by <a href="https://css-tricks.com/author/chriscoyier/"><strong>Chris Coyier</strong></a>.</p><p>So let’s say we have the following html document:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FocOEcXUhLF54DstAth3h%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FocOEcXUhLF54DstAth3h&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5417a6c570609a47f3a3c11257fd71cf/href">https://medium.com/media/5417a6c570609a47f3a3c11257fd71cf/href</a></iframe><p>a very basic styles.css</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FaDIGVzFnEPBH8p3KKg8f%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FaDIGVzFnEPBH8p3KKg8f&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fapi%2Fimage%2FaDIGVzFnEPBH8p3KKg8f&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c83a0221c82dc5e9c2aee5099251a215/href">https://medium.com/media/c83a0221c82dc5e9c2aee5099251a215/href</a></iframe><p>2 theme files</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2Fw5NVB1MRDtHDNAjyEvuQ%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2Fw5NVB1MRDtHDNAjyEvuQ&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c156076de9c358639fe2aae67d9ec89/href">https://medium.com/media/4c156076de9c358639fe2aae67d9ec89/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FGCZzVyUaVf4007TnaiMQ%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FGCZzVyUaVf4007TnaiMQ&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fapi%2Fimage%2FGCZzVyUaVf4007TnaiMQ&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3528ea256a66715bd8bafef6ca825b12/href">https://medium.com/media/3528ea256a66715bd8bafef6ca825b12/href</a></iframe><p>Now, the idea is pretty simple, we can have a Service Worker to dynamically manage /assets/theme.css resource by playing with Cache API.</p><p>First, we want to link some default theme, so /assets/theme.css won’t return 404 eror as a fallback:</p><pre>ln /assets/theme-light.css /assets/theme.css</pre><p>And themes config file</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2F33TB9AF4vhYktU4uhtcf%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F33TB9AF4vhYktU4uhtcf&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/60711b5671d691682c8de132d59eec2f/href">https://medium.com/media/60711b5671d691682c8de132d59eec2f/href</a></iframe><p>Service Worker can be broken down to 3 parts:</p><ol><li>Load themes config and prefetch all css files that we may require</li></ol><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2F33TB9AF4vhYktU4uhtcf%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F33TB9AF4vhYktU4uhtcf&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/60711b5671d691682c8de132d59eec2f/href">https://medium.com/media/60711b5671d691682c8de132d59eec2f/href</a></iframe><p>2. Setup listener for messages from main browser thread, so we can update selected theme</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FTLcoILB4qBl05CiW6J80%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FTLcoILB4qBl05CiW6J80&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3bf37552d7f149ad671e6dd14217e43a/href">https://medium.com/media/3bf37552d7f149ad671e6dd14217e43a/href</a></iframe><p>3. And do the magic, replace each call to /assets/theme.css with pre-cached response for currenly selected theme</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FzR9fjvHGyh1Oh84hYIy2%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FzR9fjvHGyh1Oh84hYIy2&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fapi%2Fimage%2FzR9fjvHGyh1Oh84hYIy2&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9044c7bae701b35b0e4d4d88c1dff3b8/href">https://medium.com/media/9044c7bae701b35b0e4d4d88c1dff3b8/href</a></iframe><p>That’s basically the whole trick. All we need to do in main thread is to start the service worker and send a message each time selected theme is updated.</p><p>The whole code can be found at <a href="https://github.com/lyxsus/defart">https://github.com/lyxsus/defart</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7935f7f85e20" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>