<?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: James Thomson</title>
    <description>The latest articles on DEV Community by James Thomson (@jamesthomson).</description>
    <link>https://dev.to/jamesthomson</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%2F139188%2F5289e95d-8e5d-4f94-8d4e-29cb23e9e1bc.png</url>
      <title>DEV Community: James Thomson</title>
      <link>https://dev.to/jamesthomson</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jamesthomson"/>
    <language>en</language>
    <item>
      <title>Native cloning is coming to Javascript soon!</title>
      <dc:creator>James Thomson</dc:creator>
      <pubDate>Thu, 16 Dec 2021 23:52:02 +0000</pubDate>
      <link>https://dev.to/jamesthomson/native-cloning-is-coming-to-javascript-soon-4640</link>
      <guid>https://dev.to/jamesthomson/native-cloning-is-coming-to-javascript-soon-4640</guid>
      <description>&lt;p&gt;If you've ever wondered "why doesn't Javascript have a method to deep clone?", you wouldn't be the only one.&lt;/p&gt;

&lt;p&gt;For years we've been using various methods or libraries to clone objects and it's never felt quite right. Thankfully, &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/structuredClone"&gt;&lt;code&gt;structuredClone&lt;/code&gt;&lt;/a&gt; is coming to a browser near you! Don't get scared off by the &lt;a href="https://caniuse.com/?search=structuredClone"&gt;sea of red&lt;/a&gt; for browser support. All browsers have implemented it in their nightly releases, so it's on the way.&lt;/p&gt;

&lt;p&gt;How do we use it you say? Simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const myObj = {
  title: 'Something',
  myNestedObj: {
    title: 'Something else',
    // ... and so on
  }
}
const myDeepCopy = structuredClone(myObj);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. You now have a deep clone of your object. There are &lt;a href="https://web.dev/structured-clone/#features-and-limitations"&gt;some limitations&lt;/a&gt; to be aware of though.&lt;/p&gt;

&lt;p&gt;As always,&lt;br&gt;
Happy coding! 🤓&lt;br&gt;
&lt;a href="https://unsplash.com/photos/QtiZpH_N2sA"&gt;Cover photo credit&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Pro Tip: Use a screen recorder to debug DOM mutations</title>
      <dc:creator>James Thomson</dc:creator>
      <pubDate>Thu, 30 Apr 2020 05:13:57 +0000</pubDate>
      <link>https://dev.to/jamesthomson/pro-tip-use-a-screen-recorder-to-debug-dom-mutations-2dcf</link>
      <guid>https://dev.to/jamesthomson/pro-tip-use-a-screen-recorder-to-debug-dom-mutations-2dcf</guid>
      <description>&lt;p&gt;These days as web developers we have a plethora of various tools to help us debug. Everything from network to memory to performance issues can debugged from DevTools. But there is one thing that there doesn't seem to be a tool for (at least that I know of); a DOM mutations timeline.&lt;/p&gt;

&lt;p&gt;When you're dealing with a fair number of DOM mutations (think transitioning of elements) there can be a lot going on - too much for the eye to catch on its own. Sure you could stare at inspect and repeat the action over and over again to try and catch it... or you could make a screen recording and then scrub through the video 😉&lt;/p&gt;

&lt;p&gt;Personally I use Quicktime (perhaps someone can suggest a good app for Windows in the comments). It comes free with Mac and has everything I need to select an area of my screen to record. Just launch Quicktime and select  File &amp;gt; New Screen Recording to get started - simple.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TmUGmDP8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ussaaa8wuygb2vupsprj.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TmUGmDP8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ussaaa8wuygb2vupsprj.gif" alt="Example of screen capture gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Above I'm using this technique to debug a z-index stacking order issue when new cards are added to the stack.&lt;/p&gt;

&lt;p&gt;So there you go, another tool to add to your debugging toolbelt.&lt;/p&gt;

&lt;p&gt;As always,&lt;br&gt;
Happy coding! 🤓&lt;/p&gt;

</description>
      <category>html</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>React Devs &amp; Orgs to Follow on Twitter?</title>
      <dc:creator>James Thomson</dc:creator>
      <pubDate>Fri, 22 Nov 2019 00:34:37 +0000</pubDate>
      <link>https://dev.to/jamesthomson/react-devs-orgs-to-follow-on-twitter-4d3</link>
      <guid>https://dev.to/jamesthomson/react-devs-orgs-to-follow-on-twitter-4d3</guid>
      <description>&lt;p&gt;Hi all, I've been in the Vue world for a few years now and so React took a bit of a sideline. Now it's time to sharpen my skills in React. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What developers or organisations do you follow on Twitter to keep up with the latest React related news, techniques, patterns, etc.?&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>discuss</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>5 Things To Do When You're Feeling The Struggle</title>
      <dc:creator>James Thomson</dc:creator>
      <pubDate>Fri, 30 Aug 2019 04:03:36 +0000</pubDate>
      <link>https://dev.to/jamesthomson/5-things-to-do-when-you-re-feeling-the-struggle-37g3</link>
      <guid>https://dev.to/jamesthomson/5-things-to-do-when-you-re-feeling-the-struggle-37g3</guid>
      <description>&lt;p&gt;Being a developer does not come without its heartache. We deal with complex requests, tight deadlines, and unforeseen variables (e.g. major change requests).&lt;/p&gt;

&lt;p&gt;It's always good to have a few strategies in your pocket when dealing with these so you don't go full Homer and tear all your hair out.&lt;/p&gt;

&lt;p&gt;So, let's get to the list...&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Take a Break
&lt;/h2&gt;

&lt;p&gt;This one isn't always easy to do when you're on a tight deadline, but more often than not it will help greatly. Most of the time the answer is right there in front of you, but you're just too wrapped up in the problem to see it. By taking a break it'll help you refocus and think about the problem with a different mindset.&lt;/p&gt;

&lt;p&gt;I work from home, so some things I'll do are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Throw the ball for the dogs&lt;/li&gt;
&lt;li&gt;Have a shower (you'd be surprised how many good ideas are shower ideas)&lt;/li&gt;
&lt;li&gt;Go for a walk&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For those that work in an office:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go for a cup of coffee/tea&lt;/li&gt;
&lt;li&gt;Go for a walk around the block&lt;/li&gt;
&lt;li&gt;Run a quick errand&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Basically, just get away from the screen to clear your mind up a bit and consider new angles to the problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Work on Something Else
&lt;/h2&gt;

&lt;p&gt;Similar to the above, this allows you to take a break from the problem at hand, but still get some other work done. Perhaps it's another feature or just some admin stuff that's been piling up. Stepping away from the problem should help you refocus.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Talk it Out
&lt;/h2&gt;

&lt;p&gt;Often called &lt;a href="https://en.wikipedia.org/wiki/Rubber_duck_debugging"&gt;"rubber ducking"&lt;/a&gt;, this method is as simple as talking out the problem to yourself. It forces you to stop and think about the problem aloud.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Write it Out
&lt;/h2&gt;

&lt;p&gt;Similar to talking it out, writing out your problem helps you see it in a new light. Go through the problem and write it out step by step to help you visualize it.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Ask for Help
&lt;/h2&gt;

&lt;p&gt;And last, but not least, never be too proud to ask for help. Often the solution is right in front of you, but just requires another set of eyes or perspective to see it. Whether you seek help from your colleagues, community forums, or chat, this is a great way to work through a problem.&lt;/p&gt;




&lt;p&gt;The above list may seem pretty straightforward and that's because it is. The main thing to remember is to just stop and think before you get overwhelmed and frustrated.&lt;/p&gt;

&lt;p&gt;I'm sure we all have our own strategies to deal with the struggle. What are some of yours?&lt;/p&gt;

&lt;p&gt;As always,&lt;br&gt;
Happy coding! 🤓&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>productivity</category>
      <category>career</category>
      <category>beginners</category>
    </item>
    <item>
      <title>SVG Tricks: Kickass Hotspots!</title>
      <dc:creator>James Thomson</dc:creator>
      <pubDate>Thu, 01 Aug 2019 09:29:30 +0000</pubDate>
      <link>https://dev.to/jamesthomson/svg-tricks-kickass-hotspots-904</link>
      <guid>https://dev.to/jamesthomson/svg-tricks-kickass-hotspots-904</guid>
      <description>&lt;p&gt;&lt;em&gt;Precursor: This article assumes you know the basics of SVG. If you haven't already discovered SVG then there's no time like today. The power behind the features of SVG are quite amazing and oh so useful. Today we're going to be talking about just one of those features.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;As you're probably already well aware, everything on a website is a box. We can style elements to look like they're not boxes, but ultimately the element and the room it takes up is a box.&lt;/p&gt;

&lt;p&gt;For the most part this isn't an issue. A lot of what we create fits quite nicely in a box, but what do we do when we have to create something that doesn't really fit that model?&lt;/p&gt;

&lt;p&gt;For example, let's say we have the image below and need each character to be clickable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fw5l569wg06kb2ct3kudp.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fw5l569wg06kb2ct3kudp.jpg" alt="Move poster of main characters from Kick Ass 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point you may be thinking, "Well, I could just use an &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/map" rel="noopener noreferrer"&gt;image map&lt;/a&gt;", which is true, but also limiting and tedious to work with.&lt;/p&gt;

&lt;p&gt;Another solution could be to just absolutely position some elements overtop of the image like so: &lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://jsfiddle.net/jamesbrndwgn/hvtcnsrj//embedded/result,html,css//dark" width="100%" height="600"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;However, you'll notice because the characters overlap each other it becomes quite difficult to reliably select the character you want. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;

&lt;p&gt;So, as I'm sure you've already guessed, our solution is going to be to use SVG! Using Illustrator (but you can use Inkscape, or any other preferred tool to create SVG's, of course) I imported the image and used the pen tool to create paths around each character.&lt;/p&gt;

&lt;p&gt;Here's what that looked like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6wt36xzd43mxbacqzzm1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6wt36xzd43mxbacqzzm1.png" alt="Move poster of main characters from Kick Ass 2 with hotspot paths"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Not very pretty, I know, but we'll clean things up a bit in the code.&lt;/p&gt;

&lt;p&gt;Simply by changing our paths fill attribute to transparent we now have invisible hit areas that perfectly (well, as perfectly as you make them 😉) trace our characters...&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://jsfiddle.net/jamesbrndwgn/6zp92kg0/5//embedded/result,html,css//dark" width="100%" height="600"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Pretty cool, eh? Add a splash of javascript and some CSS and the world is your oyster. Oh, and did I mention it's all completely fluid?&lt;/p&gt;

&lt;h2&gt;
  
  
  Just For Fun
&lt;/h2&gt;

&lt;p&gt;I wanted to see if I could achieve the same over a video and turns out with a bit of absolute positioning, it's certainly attainable, as you can see below:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://jsfiddle.net/jamesbrndwgn/pjwhez4y/2//embedded/result,html,css//dark" width="100%" height="600"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;So there you have it, go forth, try your own out and post what you come up with in the comments. 🙂&lt;/p&gt;

&lt;p&gt;And as always, happy coding! 🤓&lt;/p&gt;

</description>
      <category>svg</category>
      <category>webdev</category>
      <category>html</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Wanted: JavaScript Book Recommendations</title>
      <dc:creator>James Thomson</dc:creator>
      <pubDate>Thu, 18 Jul 2019 01:23:35 +0000</pubDate>
      <link>https://dev.to/jamesthomson/wanted-javascript-book-recommendations-j4c</link>
      <guid>https://dev.to/jamesthomson/wanted-javascript-book-recommendations-j4c</guid>
      <description>&lt;p&gt;I consider myself to have a pretty decent knowledge of JavaScript, but I know there's ALWAYS more to learn. I'm looking for some paperback book recommendations to take my knowledge to the next level, really get into the intricacies of JS - and boy are there many!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;So, what are your must read JavaScript book recommendations?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Edit: Thanks all for the recommendations, looks like I have some reading to do!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Prefix vs Postfix When Using Increment &amp; Decrement Operators.</title>
      <dc:creator>James Thomson</dc:creator>
      <pubDate>Mon, 01 Jul 2019 03:59:34 +0000</pubDate>
      <link>https://dev.to/jamesthomson/prefix-vs-postfix-when-using-increment-decrement-operators-220f</link>
      <guid>https://dev.to/jamesthomson/prefix-vs-postfix-when-using-increment-decrement-operators-220f</guid>
      <description>&lt;p&gt;&lt;em&gt;Cover photo: &lt;a href="https://unsplash.com/photos/4W5WWKaxsKs"&gt;@markusspiske&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Whether you've been using JavaScript for 10 days or 10 years, you've most certainly come across and have used the increment (&lt;code&gt;++&lt;/code&gt;) and decrement (&lt;code&gt;--&lt;/code&gt;) operators.&lt;/p&gt;

&lt;p&gt;But were you aware that how you use these on the operand will differ when used prefixed as opposed to postfixed?&lt;/p&gt;

&lt;h2&gt;
  
  
  The Difference
&lt;/h2&gt;

&lt;p&gt;First, let's see what happens when we use a postfixed increment operator.&lt;/p&gt;

&lt;p&gt;Given this statement, what would you expect the console to log?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let count = 0
console.log(count++)
console.log(count)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You may have been expecting it to log 1 for both, but this isn't the case. It will log 0 and then 1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let count = 0
console.log(count++) // 0
console.log(count) // 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why? Because postfixed operators will return the value of the operand &lt;strong&gt;before&lt;/strong&gt; applying the operator.&lt;/p&gt;

&lt;p&gt;Now, let's try the exact same code, but with a prefixed operator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let count = 0
console.log(++count) // 1
console.log(count) // 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, the operator is now first applied and then the value is returned &lt;strong&gt;after&lt;/strong&gt;.&lt;/p&gt;

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

&lt;p&gt;So what's the take away here? I think really just to be aware of the intricacies of JavaScript. There's no harm in using these operators, but you should be aware of how it will affect your code. Sometimes it can even be better to go the explicit route: &lt;code&gt;count = count+1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Either way, I hope you learned something!&lt;/p&gt;

&lt;p&gt;As always,&lt;br&gt;
Happy Coding 🤓&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Are portfolios still necessary as a front end developer?</title>
      <dc:creator>James Thomson</dc:creator>
      <pubDate>Wed, 19 Jun 2019 01:12:20 +0000</pubDate>
      <link>https://dev.to/jamesthomson/are-portfolios-still-necessary-as-a-front-end-developer-1geg</link>
      <guid>https://dev.to/jamesthomson/are-portfolios-still-necessary-as-a-front-end-developer-1geg</guid>
      <description>&lt;p&gt;It's been a few years since I've had to go through the job seeking process and I'm curious, is it still the norm to have a portfolio site as a front end developer?&lt;/p&gt;

&lt;p&gt;Some of us, myself included, work on a single web app over the course of a few years so a portfolio of recent work is going to be pretty sparse. Of course a lot of work has gone in to the site so different aspects could be featured, but is it overkill to have a portfolio for this?&lt;/p&gt;

&lt;p&gt;None of the job postings I've seen for front end developers make any mention of sending your portfolio, which is why I wonder if it's still a necessity.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Edit: Thanks for the feedback everyone. It seems the consensus is that having a personal site is worthwhile and a great place to gather your past experience, experiments, and just general thoughts. All very useful for obtaining potential employment opportunities.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>webdev</category>
      <category>career</category>
    </item>
    <item>
      <title>Google IO: Chrome is closing the gap between web and native</title>
      <dc:creator>James Thomson</dc:creator>
      <pubDate>Thu, 09 May 2019 04:02:08 +0000</pubDate>
      <link>https://dev.to/jamesthomson/google-io-chrome-is-closing-the-gap-between-web-and-native-42f2</link>
      <guid>https://dev.to/jamesthomson/google-io-chrome-is-closing-the-gap-between-web-and-native-42f2</guid>
      <description>&lt;p&gt;This years Google IO is full of awesome new tech, but one I am most excited about is the effort to "close the gap" between web and native.&lt;/p&gt;

&lt;p&gt;The livestream presentation isn't up yet, but you can access the Codelab here:&lt;br&gt;
&lt;a href="https://codelabs.developers.google.com/codelabs/web-capabilities"&gt;https://codelabs.developers.google.com/codelabs/web-capabilities&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There's also more information (under the title "Creating a more powerful web") here: &lt;a href="https://blog.chromium.org/2019/05/google-io-2019-whats-new-with-chrome.html"&gt;https://blog.chromium.org/2019/05/google-io-2019-whats-new-with-chrome.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By the sound of it, most of these API's are scheduled for Chrome 78+ so we've still got a way to go, but it all sounds very promising.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What are your thoughts?&lt;/em&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>chrome</category>
    </item>
    <item>
      <title>Sublime 3: Goto Anything... Tip</title>
      <dc:creator>James Thomson</dc:creator>
      <pubDate>Tue, 07 May 2019 05:18:36 +0000</pubDate>
      <link>https://dev.to/jamesthomson/sublime-3-goto-anything-tip-190b</link>
      <guid>https://dev.to/jamesthomson/sublime-3-goto-anything-tip-190b</guid>
      <description>&lt;p&gt;If you use Sublime 3 you're likely used to using &lt;code&gt;Goto Anything...&lt;/code&gt; (CMD+P Mac, CTRL+P Windows) to quickly bring up files. One downside is this will bring up vendor and compiled files as well. This really isn't ideal. So to fix this you can exclude these directories. &lt;/p&gt;

&lt;p&gt;Open up your user settings and add this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"binary_file_patterns": ["node_modules/", "public/", "vendor/", "*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds", "*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip"],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you add other folders, just be sure to suffix them with a "/".&lt;/p&gt;

&lt;p&gt;Then save the file and you should be good to go.&lt;/p&gt;

&lt;p&gt;As always, happy coding! 🤓&lt;/p&gt;

</description>
      <category>sublime</category>
      <category>productivity</category>
      <category>css</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Naming things is hard. Agree or disagree? </title>
      <dc:creator>James Thomson</dc:creator>
      <pubDate>Wed, 01 May 2019 03:29:59 +0000</pubDate>
      <link>https://dev.to/jamesthomson/naming-things-is-hard-agree-or-disagree-1ln6</link>
      <guid>https://dev.to/jamesthomson/naming-things-is-hard-agree-or-disagree-1ln6</guid>
      <description>&lt;p&gt;I've been a web developer for 10+ years now, mostly on the front-end, and I still find it difficult to name CSS classes, especially as a project grows. I've been using BEM for awhile and while this helps keep things scoped, there comes a time when you've used up a lot of the common component names and have to start getting more creative. So much so that I've resorted to keeping a (growing) &lt;a href="https://gist.github.com/james-brndwgn/2e5b2c6ae7c41e0af79dec5292742929"&gt;gist of names&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Funnily enough, I don't seem to have this problem in naming JS components (for the most part). I work a lot with Vue and am thinking of trying out CSS Modules/scoped CSS in hopes it eliminates the need for CSS component names that BEM creates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are some strategies you use when naming things?&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>webdev</category>
      <category>css</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Greatly Reduce PNG Weight With This One Trick</title>
      <dc:creator>James Thomson</dc:creator>
      <pubDate>Fri, 26 Apr 2019 08:10:20 +0000</pubDate>
      <link>https://dev.to/jamesthomson/greatly-reduce-png-weight-with-this-one-trick-4p0g</link>
      <guid>https://dev.to/jamesthomson/greatly-reduce-png-weight-with-this-one-trick-4p0g</guid>
      <description>&lt;p&gt;&lt;em&gt;Preface: In this article I'm assuming you're already familiar with SVG. If not, now's a great time to &lt;a href="https://www.w3schools.com/graphics/svg_intro.asp" rel="noopener noreferrer"&gt;familiarise yourself&lt;/a&gt;! The power of SVG is truly amazing.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;More than likely you've found yourself in this situation... You get handed a design, it's beautiful and full of color and images. &lt;/p&gt;

&lt;p&gt;The designer then informs you that the hero banner has text that changes and so does the background color.&lt;/p&gt;

&lt;p&gt;Here's what that hero banner may look like (though likely far better designed, but hey, it gets the point across):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ftpr6l76i9im41y9hc0uu.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ftpr6l76i9im41y9hc0uu.jpg" alt="Ice cream hero banner design"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ok, no problem, that means we can't just use a background image and be done with it, we need to break the hero up into piece so portions of it can be dynamic.&lt;/p&gt;

&lt;p&gt;Usually you'd reach to a PNG for the ice cream cone image. But, PNGs are usually pretty big, especially once we start catering to high DPI screens. &lt;strong&gt;Our ice cream as a PNG would clock in at a whopping 1.9mb!&lt;/strong&gt; So instead, we're going to use a trick with &lt;a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/mask" rel="noopener noreferrer"&gt;SVG masks&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Flltqlgebz3qwcenhqfz2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Flltqlgebz3qwcenhqfz2.jpg" alt="Isolated ice cream image and mask"&gt;&lt;/a&gt;&lt;/p&gt;
Jpg (left) 292kb, 8-bit PNG (right) 17kb



&lt;p&gt;First, we're going to save our ice cream as a jpg. I'll use a black background in place of the transparency.&lt;/p&gt;

&lt;p&gt;Next, we'll save another image as an 8-bit png to use as the mask image. Any part that is black will be invisible and any part that is white will be visible.&lt;/p&gt;

&lt;p&gt;Those 2 images we'll then use together in our SVG like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMinYMin" version="1.1" viewBox="0 0 938 1912"&amp;gt;
  &amp;lt;defs&amp;gt;
    &amp;lt;mask id="mask"&amp;gt;
      &amp;lt;image width="938" height="1912" xlink:href="/images/ice-cream-mask.png"/&amp;gt;
    &amp;lt;/mask&amp;gt;
  &amp;lt;/defs&amp;gt;
  &amp;lt;image mask="url(#mask)" width="938" height="1912" xlink:href="/images/ice-cream.jpg"/&amp;gt;
&amp;lt;/svg&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can reference the images as seen in the code above or you can even inline them as &lt;a href="https://www.base64-image.de/" rel="noopener noreferrer"&gt;base64&lt;/a&gt; which you can see in this Codepen.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/getreworked/embed/QPzxwB?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;And there you have it. We've gone from a &lt;strong&gt;1.9mb transparent PNG to roughly 309kb SVG without compromising quality or transparency&lt;/strong&gt;. Pretty sweet, hey?&lt;/p&gt;

&lt;p&gt;As always, happy coding! 🤓&lt;/p&gt;

&lt;p&gt;&lt;em&gt;It should be noted, I haven't tested all the browsers out there, but SVG support is now very wide spread so I wouldn't expect many issues. That said, if you've encountered any, let me know in the comments.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;You can also use this &lt;a href="https://codepen.io/shshaw/full/IDbqC/" rel="noopener noreferrer"&gt;great Codepen to help with your tests&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>svg</category>
      <category>html</category>
      <category>optimization</category>
    </item>
  </channel>
</rss>
