<?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 Will Po on Medium]]></title>
        <description><![CDATA[Stories by Will Po on Medium]]></description>
        <link>https://medium.com/@will.po?source=rss-ec9acadcbea7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nXYyeV6G5LuvZiBAeTIZaw.png</url>
            <title>Stories by Will Po on Medium</title>
            <link>https://medium.com/@will.po?source=rss-ec9acadcbea7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 17:32:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@will.po/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[Body scroll lock — making it work with everything]]></title>
            <link>https://medium.com/jsdownunder/locking-body-scroll-for-all-devices-22def9615177?source=rss-ec9acadcbea7------2</link>
            <guid isPermaLink="false">https://medium.com/p/22def9615177</guid>
            <category><![CDATA[body-scroll]]></category>
            <category><![CDATA[modal]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-scroll-lock]]></category>
            <dc:creator><![CDATA[Will Po]]></dc:creator>
            <pubDate>Wed, 24 Jan 2018 06:19:38 GMT</pubDate>
            <atom:updated>2018-02-14T21:07:28.948Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XAi1FRsBgjsXhUSm4GW0AA.jpeg" /></figure><p>Have a google of how people lock the body scroll and you’ll come across a few solutions to accomplish this. The basic use case is:</p><ol><li>Enable some targetElement to appear above the body with position: absolute.</li><li>After it appears, use some solution to disable body scrolling so scrolling within the targetElement doesn’t scroll the body content.</li></ol><p>Here are the likely solutions you’ll come across:</p><h3>1. CSS Overflow</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a979324e97b998c9d9141b7112668023/href">https://medium.com/media/a979324e97b998c9d9141b7112668023/href</a></iframe><p>This approach works for desktop browsers, and mobile Android. However, it fails for mobile iOS (phone and tablets). OK, let’s try approach <strong>#2</strong>.</p><h3>2. Prevent Default</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3f78cfa11636bc9f98453704629b43f/href">https://medium.com/media/e3f78cfa11636bc9f98453704629b43f/href</a></iframe><p>Great solution — scrolling is blocked! But it also blocks scrolling inside the targetElement. If content in the targetElement has height exceeding the element’s set height, you will want to have it scroll!!!!!</p><h3>3. Position Fixed</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a0734d88b1eb270a7f7bd10ecc803afb/href">https://medium.com/media/a0734d88b1eb270a7f7bd10ecc803afb/href</a></iframe><p>If you make the body position: fixed, the body will scroll to the top thus losing the body’s original scroll position. Not ideal UX!</p><h3>Proposed Solution — body-scroll-lock</h3><blockquote>Body scroll locking that just works with everything 😏</blockquote><p>Since all devices except iOS respect the overflow: hidden on the html/bodyelements, we can use this approach for these devices.</p><p>For iOS — we check if targetElement has been scrolled to the bottom or top. If it has, then apply the e.preventDefault() solution. Some Javascript is needed to determine this.</p><p>The logic to achieve the proposed solution can be found <a href="https://github.com/willmcpo/body-scroll-lock/blob/master/src/bodyScrollLock.js"><strong>here</strong></a>.</p><p>For convenience, the solution can be downloaded as an NPM package<strong> </strong><a href="https://www.npmjs.com/package/body-scroll-lock"><strong>body-scroll-lock</strong></a><strong> </strong>and used in projects using vanilla JS or frameworks such as React.</p><p>(btw, if you found the <a href="https://www.npmjs.com/package/body-scroll-lock"><strong>body-scroll-lock</strong></a><strong> </strong>package useful, please star the <a href="https://github.com/willmcpo/body-scroll-lock"><strong>GitHub repo</strong></a> to help others solve their body scroll locking issues more easily!).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22def9615177" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jsdownunder/locking-body-scroll-for-all-devices-22def9615177">Body scroll lock — making it work with everything</a> was originally published in <a href="https://medium.com/jsdownunder">jsdownunder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Webpack — Build Performance Pitfall of using SASS with CSS Modules]]></title>
            <link>https://medium.com/jsdownunder/webpack-build-performance-pitfall-of-using-sass-with-css-modules-ba32f89efdcb?source=rss-ec9acadcbea7------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba32f89efdcb</guid>
            <category><![CDATA[sass]]></category>
            <category><![CDATA[slow-build]]></category>
            <category><![CDATA[css-modules]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[webpack]]></category>
            <dc:creator><![CDATA[Will Po]]></dc:creator>
            <pubDate>Tue, 01 Aug 2017 07:29:20 GMT</pubDate>
            <atom:updated>2018-01-26T10:46:43.605Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LZZ9Sr4XL7j2-LjSJ5uq9Q.jpeg" /></figure><p>Many people looking to combine the power of SASS with modularised stylesheets will use <a href="https://github.com/webpack-contrib/css-loader">CSS Modules</a>.</p><p>It’s an obvious choice.</p><p>When using <a href="https://github.com/webpack/webpack">Webpack</a> as your bundler, you’ll likely use <a href="https://github.com/webpack-contrib/sass-loader">sass-loader</a> to transpile the SASS. An example of the Webpack loaders configuration used to do this:</p><pre>{<br>  test: /\.sass$/,<br>  use: [<br>    {<br>      loader: &#39;style-loader&#39;,<br>      options: {<br>        sourceMap: <strong>true</strong>,<br>      },<br>    },<br>    {<br>      loader: &#39;css-loader&#39;,<br>      options: {<br>        sourceMap: <strong>true</strong>,<br>        modules: <strong>true</strong>,<br>        importLoaders: 3,<br>        localIdentName: &#39;[folder]--[local]--[hash:base64:2]&#39;,<br>      }<br>    },<br>    &#39;postcss-loader&#39;,<br>    &#39;resolve-url-loader&#39;,<br>    {<br>      loader: &#39;sass-loader&#39;,<br>      options: {<br>        sourceMap: <strong>true</strong>,<br>        indentedSyntax: <strong>true</strong>,<br>      }<br>    }<br>  ]<br>},</pre><pre>{<br>  test: /\.sass$/,<br>  use: [<br>    {<br>      loader: &#39;style-loader&#39;,<br>      options: {<br>        sourceMap: <strong>true</strong>,<br>      },<br>    },<br>    {<br>      loader: &#39;css-loader&#39;,<br>      options: {<br>        sourceMap: <strong>true</strong>,<br>        modules: <strong>true</strong>,<br>        importLoaders: 3,<br>        localIdentName: &#39;[folder]--[local]--[hash:base64:2]&#39;,<br>      }<br>    },<br>    &#39;postcss-loader&#39;,<br>    &#39;resolve-url-loader&#39;,<br>    {<br>      loader: &#39;sass-loader&#39;,<br>      options: {<br>        sourceMap: <strong>true</strong>,<br>        indentedSyntax: <strong>true</strong>,<br>      }<br>    }<br>  ]<br>},</pre><h3>The Problem — Exponentially Increasing Build Times</h3><p>Part of the problem with <a href="https://github.com/webpack-contrib/sass-loader">sass-loader</a> (<em>which uses node-sass underneath</em>), is that transpiled SASS files are not cached. Also, when sass-loader is used with CSS Modules, every component’s stylesheet is modularised, and <em>so each of these will spawn its own SASS process, </em>and your dual/quad core CPU will try to run all these processes simultaneously with tremendous overhead. Most likely these stylesheets will import some common SASS modules (eg. breakpoints, mixins, variables, colours, etc), and since there’s no cached transpilation, this means these common SASS modules will get transpiled to CSS over and over and over and over…</p><h4>Exponentially Increasing Build Times</h4><p>For our team, this led to exponential increases in the start up time of our Webpack Dev Server from a few seconds when the project was started, to about 3–6 minutes after a few months worth of new components and changes.</p><p>Most of the time, we don’t need to restart our dev server due to the hot-reloading that we’ve configured. But often we’ll have to do one of: switch to another branch which requires <a href="https://github.com/yarnpkg/yarn">yarn</a> to be run, switch to another repo/branch to do a code review, restart the computer or restart the app for some reason…</p><h4>Bad Developer Experience</h4><blockquote>Needless to say, every restart was a massive drain on productivity, momentum, and the developer experience (ie. dev happiness), which further affects productivity! — and so we took drastic action!</blockquote><h3>Our Solution</h3><blockquote>Get rid of SASS!</blockquote><blockquote>Ok — well, what do you use instead?</blockquote><h4>PostCSS / CSSNext.</h4><p>Most of the stuff you want to do in SASS, you can already do with tomorrow’s CSS syntax with the help of <a href="https://github.com/postcss/postcss">PostCSS</a> and <a href="http://cssnext.io/">CSSNext</a>.</p><blockquote>After converting all our component’s stylesheets from SASS to CSS, our build time has pretty much dropped by 50% to about 1.5 minutes.</blockquote><p><strong><em>1.5 minutes!</em></strong> Still much higher than desired, but a massive improvement in productivity for us.</p><h3>Conclusion</h3><p>If you’re starting a new project and looking to use CSS Modules, <em>strongly consider using PostCSS/CSSNext from the start, and don’t use SASS at all. </em>You will save yourself a lot of time down the long run!</p><p>On the other hand, if you are already using CSS Modules with SASS and are experiencing increasing build times, take comfort in knowing that if you take the plunge (and short-term pain) to convert all your SASS to CSS, <em>you can reduce the build time by ~50%!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba32f89efdcb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jsdownunder/webpack-build-performance-pitfall-of-using-sass-with-css-modules-ba32f89efdcb">Webpack — Build Performance Pitfall of using SASS with CSS Modules</a> was originally published in <a href="https://medium.com/jsdownunder">jsdownunder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>