<?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 Joscelyn James on Medium]]></title>
        <description><![CDATA[Stories by Joscelyn James on Medium]]></description>
        <link>https://medium.com/@josce.james7?source=rss-40e8bd737a72------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*g6qEskNDflP5-8eHlRIJ8w.jpeg</url>
            <title>Stories by Joscelyn James on Medium</title>
            <link>https://medium.com/@josce.james7?source=rss-40e8bd737a72------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 19:01:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@josce.james7/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[A Developers Guide to SVGs]]></title>
            <link>https://medium.com/@josce.james7/a-developers-guide-to-svgs-5e171143cfa2?source=rss-40e8bd737a72------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e171143cfa2</guid>
            <category><![CDATA[svg]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Joscelyn James]]></dc:creator>
            <pubDate>Mon, 21 Sep 2020 14:43:05 GMT</pubDate>
            <atom:updated>2020-09-21T14:49:04.457Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EttLNsF3yfb3w8Is" /><figcaption>Photo by <a href="https://unsplash.com/@gcalebjones?utm_source=medium&amp;utm_medium=referral">Caleb Jones</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you are reading this article, you probably have seen or used the `.svg` file extension from time to time. And you might just think that it’s another format for an image — you aren’t completely wrong, but SVGs have unique characteristics that set them apart from other image formats… I’m talking about vectors. Traditional images are rendered with bitmaps that tell the computer what color each pixel should be vs SVG image are made up of vectors. These vectors can be thought of as a set of instructions that tell the computer how to draw the image. In this article, I will guide you down the path to SVG; we will cover what an SVG is, when to use them, and how to create them. Let’s begin!</p><h3>What is SVG?</h3><blockquote>SVG — or Scalable Vector Graphic — is an XML based language that is used to build 2 deminsional graphics on the web.</blockquote><p>SVG is no stranger to the web, in fact, SVGs have been around officially since 2001. It was created by a team at W3C and out beat 6 other submissions for a vector-based graphics on the web — Some of those competing teams included members from IBM, Microsoft, and Adobe! With more recent support from most browsers, SVGs have been picking up in popularity. Vector images are to use on the web do to their scaling, size, compression, accessibility, etc.. We will explore some of the benefits of using SVGs and when it’s appropriate to use them.</p><h3>When and Why To use SVGs</h3><p>SVGs are very versatile and can be used for very basic implementations, like icons to something more dynamic like animations. Something to keep in mind is that an SVG won&#39;t be as high of detail compared to a bitmap image such as .png. For example, take these two images below: the image on the left is a photo you would take with a camera, which is stored as a .jpg (bitmap) file on your computer. Compare this to the one on the right which is our .svg (vector) image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*08QqfWFXfX1dqbijB-s2eg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BSxD0mh0DFm4YpvBkWBjzQ.jpeg" /><figcaption>High Resolution and High Detail picture of a dog vs Low Detail illustration of a dog</figcaption></figure><h4>Why?</h4><p>Let’s take a look at some reasons why you should consider using SVGs:</p><p><strong>Reduce bundle size — </strong>they’re smaller than traditional bitmap images and can easily be compressed to be even smaller!</p><p><strong>Increase performance and load times — </strong>we discussed how they are small, this allows you to reduce the amount of data you are passing or hosting. Web browsers can render them really fast since it’s in an XML format.</p><p><strong>Scaling — </strong>by design, SVGs can scale really big or really small without pixelation or loss in quality.</p><p><strong>Animations — </strong>probably my favorite part of an SVG! You get full control of it and all it’s children elements. This allows developers and designers to make beautiful animations that can be optimized for the web.</p><p><strong>SEO — </strong>since this is mainly text, this greatly increases the SEO of your site.</p><p><strong>Accessibility — </strong>you can use DOM attributes on an SVG just like you would any HTML element.</p><h4>When?</h4><p>Now since I have you on board with why we should use SVGs, let&#39;s look into some scenarios they are a great use case for!</p><p><strong>Icons</strong></p><p>By design, SVGs can scale really big or really small without pixelation or loss in quality. This makes them perform great in responsive designs. A single SVG will work for a favicon icon all the way up to a full-page icon!</p><p><strong>Web Animations</strong></p><p>Adding animations to your website is so easy with SVG! You have full control of the SVG and can manipulate that element just like any other DOM node. SVGs and their children elements can respond to click events, be assigned classes, use CSS transitions, and more. This gives developers full control of their animations using the same tools they’re used to using. If you are wanting powerful animations without the headache of CSS there are plenty of great JS libraries out there. I would recommend checking out <a href="https://animejs.com/">Anime.js </a>and <a href="https://greensock.com/gsap/">GSAP</a> — check out all of GSAPs features for FREE on codepen!</p><p><strong>Interactive Graphs</strong></p><p>If you are needing a 2-dimensional graph — look no further. SVGs make amazing, lightweight, fast, and customizable graphs. But don’t take my word, check out <a href="http://www.amcharts.com/">AMCharts</a>, they have been making beautiful charts for some major clients like Amazon, Apple, and NASA.</p><h3>How to Use SVGs</h3><p>If you already know HTML and CSS, you will have no problem picking up the gist of SVG. There are many ways to utilize an SVG in your HTML. You can use it just like you would a png or jpeg image with an img tag or as a CSS background. Although, there is a downside to these options as you will lose the ability to fully manipulate the SVG. If your only need is a sharp-looking icon at any scale, this is a great option for you.</p><p>If you are needing to manipulate that SVG with CSS or Javascript you can inline it in your HTML like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4d37d22e4984c893161bfe2014cfef8/href">https://medium.com/media/c4d37d22e4984c893161bfe2014cfef8/href</a></iframe><blockquote><strong>viewbox </strong><em>min-x</em> <em>min-y</em> <em>width</em> <em>height</em> — defines the viewable space for the given SVG. By design, an SVG is scalabe; the viewbox attribute is there to set default demisions and allow for extreme scaling without loss of quality.</blockquote><blockquote><strong>xmlns</strong> <em>svg namespace url</em> — this allows you to use SVG and all it’s glory. This only needs to be defined once at the root <em>svg</em> element.</blockquote><blockquote><strong>object — </strong>this HTML element allows you to embed external objects into a web page. Another example to use this is to embed a PDF into your page.</blockquote><p>There are pros and cons to both approaches here but they are mostly stylistic. If you go with inline an SVG, you can start to clutter up your HTML files as these graphics can get really long and (to be honest) quite ugly. If that is the case, using the HTML object tag allows you to elegantly embed these into your HTML without the clutter.</p><p>What is that you say, you are using a modern framework? Well no worries, SVG is supported in most popular frameworks like Vue, Angular, and React! In a matter of fact, SVG is well supported throughout all browsers — some older versions on IE and Android browsers do not support or have the full support of SVGs. Check out <a href="https://caniuse.com/svg">https://caniuse.com/svg</a> for more info on what is supported.</p><h3>How to Create an SVG</h3><p>SVG graphics are built inside of its own container — the size of this container is customizable by the viewbox attribute we discussed above. You can think of the container as an invisible grid that plots out our graphic based on the instructions we pass in. These instructions consist of SVG elements such as <strong>circle</strong> , <strong>path</strong> , and <strong>polygon</strong>. You also have more complicated elements like<strong>fePointLight</strong>, this element defines a light source at a given set of coordinates. Easily add motion with <strong>animateMotion</strong>, this takes a path and animates a given element along with it. Or something like<strong>foreignObject </strong>allows you to embed and use other XML namespaces inside your SVG. The most common use case for this on the web is embedding HTML into your SVG.</p><p>Let take a look at some examples!</p><pre>&lt;svg height=&quot;500px&quot; width=&quot;500px&quot; xmlns=&quot;<a href="http://www.w3.org/2000/svg">http://www.w3.org/2000/svg</a>&quot;&gt;<br> &lt;circle cx=&quot;150&quot; cy=&quot;45&quot; r=&quot;40&quot; fill=&quot;#C4C4C4&quot;/&gt;<br> &lt;rect x=&quot;220&quot; y=&quot;20&quot; height=&quot;50&quot; width=&quot;100&quot; fill=&quot;#C4C4C4&quot; /&gt; <br> &lt;path fill=&quot;none&quot; <br>       stroke=&quot;red&quot;<br>       d=&quot;M 10,30<br>          A 20,20 0,0,1 50,30<br>          A 20,20 0,0,1 90,30<br>          Q 90,60 50,90<br>          Q 10,60 10,30 z&quot; /&gt;<br> &lt;polygon fill=&quot;#C4C4C4&quot; <br>          points=&quot;400,10 <br>                  350,100 <br>                  450,50 <br>                  350,50 <br>                  450,100&quot;/&gt;<br>&lt;/svg&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*b8WchFG5IWxFJYFtQ773tw.png" /></figure><p>In the SVG above, we created four shapes. Let’s look into each shape from left to right. Something to note, the order of the elements in the SVG does not define the order in which they display. Since they are plotted on an invisible grid, we tell the SVG exactly where we want our shapes.</p><p><strong>Path</strong></p><p>On the far left, we have a heart with a red outline. This is made with an SVG path. This element is very flexible and allows you to create any shape you wish. You define your shape with x,y coordinates in the d attribute. Before each of these sets of coordinates, we have a letter dictating what effect the path should have. To start your shape off, you can tell it where the starting x,y coordinate should be by prefixing the coordinated with M. Using the letter L will draw a line from point a to point b with no fancy effects. If you are wanting a curve, using the letters S , Q , or A can be made of up multiple coordinate sets to create different Bezier curves and arcs.</p><p><strong>Circle</strong></p><p>The next one in line is our circle. Circles are very easy to build if you remember your geometry! You can give the circle a radius with the r attribute and assign it a specific x,y by the attributes cx and cy — these coordinates will be applied to the center of the circle.</p><p><strong>Rect</strong></p><p>Moving along, we have our rectangle. Probably the easiest shape to build. This needs a height and width. If you want to specify ax and y coordinate you can them as attributes.</p><p><strong>Polygon</strong></p><p>Last, but not least, we have our polygon or the star (I know it looks weird but I tried my best!). This element can be used to make any sort of shape but is a little easier to manage than a path. Polygons take however many x,y coordinate sets your heart desires. You pass them into a path attribute separated by spaces.</p><p>This only scratches the surface of what SVGs can create! You can go far beyond basic polygons and shapes with SVGs. Take a look at the full list of elements offered by SVG:</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element">SVG element reference</a></p><p>So essentially, SVGs can create amazing graphics and animations all with code! Pretty cool, right!? But what about creating precision SVGs? I couldn’t make an equilateral star, how would someone expect me to create these amazing graphics and animations?! Luckily for us, there are GUIs built to help create amazing vector graphics! Some popular options are Sketch, Adobe, and Figma — my personal favorite because it’s free and has a great community with lots of plugins to help with the design process.</p><h3>Inspiring SVGS</h3><p>**disclaimer** — I didn’t create these SVGs, but they are ones that really inspire me.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fjjperezaguinaga%2Fembed%2Fpreview%2FyuBdq%3Fheight%3D600%26slug-hash%3DyuBdq%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2Fjjperezaguinaga%2Fpen%2FyuBdq&amp;image=https%3A%2F%2Fassets.codepen.io%2F17439%2Finternal%2Fscreenshots%2Fpens%2FyuBdq.default.png%3Ffit%3Dcover%26amp%3Bformat%3Dauto%26amp%3Bha%3Dtrue%26amp%3Bheight%3D360%26amp%3Bquality%3D75%26amp%3Bv%3D2%26amp%3Bversion%3D1386777799%26amp%3Bwidth%3D640&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/e443f7986b8131a042a0c2e250d620f1/href">https://medium.com/media/e443f7986b8131a042a0c2e250d620f1/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fchrisgannon%2Fembed%2Fpreview%2FEjVyXN%3Fheight%3D600%26slug-hash%3DEjVyXN%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2Fchrisgannon%2Fpen%2FEjVyXN%2F&amp;image=https%3A%2F%2Fassets.codepen.io%2F35984%2Finternal%2Fscreenshots%2Fpens%2FEjVyXN.default.png%3Ffit%3Dcover%26amp%3Bformat%3Dauto%26amp%3Bha%3Dtrue%26amp%3Bheight%3D360%26amp%3Bquality%3D75%26amp%3Bv%3D2%26amp%3Bversion%3D1541778171%26amp%3Bwidth%3D640&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/12a4a222bbf277aa1ad379372f20dd10/href">https://medium.com/media/12a4a222bbf277aa1ad379372f20dd10/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fsdras%2Fembed%2Fpreview%2FRZGqxR%3Fheight%3D600%26slug-hash%3DRZGqxR%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2Fsdras%2Fpen%2FRZGqxR&amp;image=https%3A%2F%2Fassets.codepen.io%2F28963%2Finternal%2Fscreenshots%2Fpens%2FRZGqxR.custom.jpg%3Ffit%3Dcover%26amp%3Bformat%3Dauto%26amp%3Bha%3Dtrue%26amp%3Bheight%3D360%26amp%3Bquality%3D75%26amp%3Bv%3D2%26amp%3Bversion%3D1595796269%26amp%3Bwidth%3D640&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/312a6d6afadd742ce1d4abb71724b899/href">https://medium.com/media/312a6d6afadd742ce1d4abb71724b899/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e171143cfa2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Increase Your Apps Performance With Angular Pipes]]></title>
            <link>https://medium.com/@josce.james7/increase-your-apps-performance-with-angular-pipes-4690ff001cf9?source=rss-40e8bd737a72------2</link>
            <guid isPermaLink="false">https://medium.com/p/4690ff001cf9</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Joscelyn James]]></dc:creator>
            <pubDate>Thu, 13 Aug 2020 13:54:46 GMT</pubDate>
            <atom:updated>2020-08-13T13:54:46.268Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*At5aAnSpsPeK9fTU" /><figcaption>Photo by <a href="https://unsplash.com/@quinten149?utm_source=medium&amp;utm_medium=referral">Quinten de Graaf</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A common pattern I see new Angular developers do is call functions directly from their component templates. While this may be convenient, it’s a bad habit to fall into. One of the most powerful parts of Angular is its reactive change detection, but with great power comes great responsibility. This reactiveness can cause unnecessary rendering and scripting. Over time, or as your app sclaes, this will reduce the overall performance of your application. This is where Pipes comes in — they hijack this change detection cycle and only execute when its value has truly changed. Luckily for us, pipes are one of the many features Angular gives us out of the box. They can range from simple to complex tasks and can provide great performance gains when used correctly.</p><blockquote>Angular offers many pre-built pipes in their common package — check out the list of them <a href="https://angular.io/api/common/CommonModule#pipes">here</a>!</blockquote><h3>The Tale of Two Pipes</h3><p>Before we learn how to use pipes, let’s look at the different kinds. There are 2 different types of pipes — pure and impure. Generally speaking, you will want to stick with pure pipes as much as possible. Pure pipes will keep your code more simple, reusable, and performant.</p><p><strong>Pure Pipes</strong></p><p>Similar to a pure function in programming, a pure pipe is deterministic. This means you can expect the same results when the same arguments are provided. In order to achieve this, there should be no internal state that the pipe relies upon. This allows Angular to safely bypass it’s own change detection and only update the value when the arguments change. In this post, we will mainly explore pure pipes.</p><p><strong>Impure Pipes</strong></p><p>On the other hand, impure pipes can rely on internal sate but will change on every change detection cycle. This can really hurt performance when are working with large amounts of data. I would recommend using Angular’s OnPush change detection in conjunction with an impure pipe.</p><blockquote>For an example of an impure pipe, check out one of Angular’s pre-built <a href="https://github.com/angular/angular/blob/d1ea1f4c7f3358b730b0d94e65b00bc28cae279c/packages/common/src/pipes/async_pipe.ts#L81">AsyncPipe</a>. This pipe allows you to subscribe to an Observable or Promise from your template.</blockquote><h3>Defining a Custom Pipe</h3><p>Defining a custom pipe is really straightforward! First, you will want to create a new folder for custom pipes. It’s a common convention to end pipe files with .pipe.ts. You might notice Angular follows this pattern with other resources like components, services, modules, and more. I highly recommend following Agular’s naming convention. Not only will it help you easily navigate your codebase, but it will make it more maintainable to new or incoming developers.</p><blockquote>If you arent familiar with Angular’s Style guide, you can check out their documentation <a href="https://angular.io/guide/styleguide">here</a>!</blockquote><p>Next, you will need to import the <a href="https://angular.io/api/core/Pipe">Pipe</a> decorator and the <a href="https://angular.io/api/core/PipeTransform">PipeTransform</a> interface from @angular/core. The pipe decorator will tell angular how to inject this file into your application. This decorator allows you to give your pipe a name and set the pipe to pure or impure. PipeTransform provides the transform method. The transform method is required on all pipes. This is where you can access the pipe&#39;s values and arguments.</p><h4>Example Pipe</h4><p>In the example below, I created a pipe called ListPipe. This pipe will receive an array of strings and add a space at the end of each one. For example, the input could look something like [&#39;foo&#39;, &#39;bar&#39;, &#39;baz&#39;] and the output would be[&#39;foo &#39;, &#39;bar &#39;, &#39;baz &#39;].</p><p>Not too bad, right? With just a few lines of code, you now have a pipe that applies some basic formatting to a collection of items.</p><h4>Using Custom Pipes</h4><p>Now that we have implemented a pipe, let’s look at how to use it. In order to use a pipe in a template, you will need to declare it in a module. It’s common for pipes to be reused throughout an application and should be included in a core module as pipes will act as singletons and only need to be declared once. If this pipe will only be used in by one module, you should import it directly into that feature module. Once you’ve done that, you will be able to use your pipe in templates like this:</p><pre>&lt;p&gt;{{ myArray | list }}&lt;/p&gt;</pre><p>If your pipe took arguments you would provide a colon-separated list after the pipe name</p><pre>&lt;p&gt;{{ myArray | list:arg1:arg2 }}&lt;/p&gt;</pre><p>You can also chain multiple pipes by separating them with |</p><pre>&lt;p&gt;{{ myArray | list | anotherPipe }}&lt;/p&gt;</pre><h3>But Why Tho?</h3><p>Now you know how to declare these things but why should you go through the trouble? <strong>Performance</strong>! If you want to create a performant app with a great user experience your app needs pipes!</p><p>In order to demonstrate the impact pipes can have on performance, I created two (almost) identical applications. I used these projects to run the same test against. Both projects have a table with 1000 rows of randomly generated data and lorem ipsum. It also comes equipped with a side nav containing the row information that comes out from the left when you click a row.</p><ul><li><a href="https://stackblitz.com/edit/example-without-pipes?embed=1&amp;file=src/app/app.component.ts">example-without-pipes - StackBlitz</a></li><li><a href="https://stackblitz.com/edit/example-with-pipes?embed=1&amp;file=src/app/app.component.ts">example-with-pipes - StackBlitz</a></li></ul><h4>Decrease your apps CPU usage</h4><p>First, let’s look at the CPU usage. You can monitor the CPU usage of a webpage with the chrome dev tools. In the top right of your dev tools, go ahead and click on the 3 dot ellipsis. Slide on down to More Tools and from that menu select Performance Monitor. You should see a new pane with some graphs with live data immediately streaming into these graphs.</p><p>The first interaction I tested was opening and closing the side nav drawer. The top picture is with pipes and the bottom is without:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*dxcBUcC3CZNouKR9cFNFqA.png" /><figcaption>Example Application With Pipes</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*YS0L1RYCJC8_XqFBOKny9A.png" /><figcaption>Example Application Without Pipes</figcaption></figure><p>In both of these screenshots, you can see the spike when I opened or closed the side nav. The application without pipes has these dramatic peaks with heavy purple throughout — this is due to angular re-rendering more often than necessary. Clicking the drawer triggers Angular’s change detection and causes every function in the template to execute again — even if the input/output hasn’t changed.</p><h4>Reduce your apps scripting time</h4><p>Next, I wanted to know is how often the functions get called in either of the apps. To find out, I added a console.count(&#39;The Function Name Here&#39;) to each function. In the app without Pipes, at 1000 rows of data, each function executes 4000 times on page load! And remember that is for each function, for the 3 functions that&#39;s a grand total of 12000 calls!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fo8VXwSvuLXhM4%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Few-disgusted-parks-and-rec-o8VXwSvuLXhM4&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2Fo8VXwSvuLXhM4%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="243" frameborder="0" scrolling="no"><a href="https://medium.com/media/4040cc0383f1170877aecbd48e37a6e2/href">https://medium.com/media/4040cc0383f1170877aecbd48e37a6e2/href</a></iframe><p>Now let’s compare that to the app with pipes — each pipe executes 1000 times. Now that is better! That is a 75% decrease from the app without pipes. We are completely ignoring change detection because our values haven&#39;t changed. Angular accomplishes this by storing all values in the current view in an array. Each pipe has it’s own corresponding index in that array. This allows them to easily access that value by index to check if it has changed before it runs any computations.</p><h4>Increase FPS and Reduce GPU</h4><p>The last thing I wanted to explore was the frame rates between the apps. You can toggle Chrome’s FPS monitor under rendering in the more tools dropdown. I tested the same interaction as above— opening and closing the side nav — for both applications. Here are the two results I got — the image on the left is from the app with pipes and the image on the right is the app without pipes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*5rHosh3KN3Fj2RkEZXpKoA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*P_d-kxyBlOzF_mViLM2EZQ.png" /><figcaption>Left: With Pipes | Right: Without Pipes</figcaption></figure><p>First, let&#39;s unpack the FPS graph we see. Each green spike is when I opened or closed the side nav, you can see a clear difference between the spikes. In the app without pipes, the frame rate drops to 0 (or close to it) when the side nav is toggled. When we see FPS at or around 0, we know the user is not getting a visual response back right away. Not only does this make your app feel slow and bulky but it can really hurt your site’s conversion rates. Humans have very short attention spans and if they have to wait a second or two for their content to show, there is a good chance they will go somewhere else to find it altogether. Generally speaking, keeping your app between 30–60 FPS will provide your user with the best experience.</p><p>This report also gives you the overall GPU usage. GPU — or graphical processing unit — this is the unit in which renders your user interface. In the application with pipes, our app used 23% less GPU to render and update the page. Decreasing your GPU will in return decrease your FPS.</p><h3>The end</h3><p>Next time you are about to use a function in a template — reach for a pipe instead! Remember to keep your pipes pure, single purposed, and reusable. Sticking to these few rules will insure a performant Angular application!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4690ff001cf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Introduction To Angular Modules]]></title>
            <link>https://medium.com/@josce.james7/an-introduction-to-angular-modules-c26d441e42fa?source=rss-40e8bd737a72------2</link>
            <guid isPermaLink="false">https://medium.com/p/c26d441e42fa</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Joscelyn James]]></dc:creator>
            <pubDate>Mon, 27 Jul 2020 14:35:59 GMT</pubDate>
            <atom:updated>2020-07-27T14:35:59.054Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PjxaUpMULTLqXNpqCtz0kg.png" /><figcaption><a href="https://www.reddit.com/r/angular/comments/7sxmvx/i_made_a_simple_angular_wallpaper_feel_free_to/">img src</a></figcaption></figure><h4>Things to know before you read</h4><p>This article is geared towards people who have some experience with Angular. If this is your first time learning about Angular, go check out <a href="https://angular.io/guide/architecture">their docs</a> on getting started!</p><h3>What are Angular modules?</h3><p>Angular defines modules as <em>a metadata object that describes how to compile a component’s template and how to create an injector at runtime. </em>In other words, a module is a group of components, directives, pipes, and services that you want to make available in parts of your Angular application. These modules should have a single responsibility and be extensible to help you build your Angular application.</p><h3>Common Types of Modules</h3><h4>App Module</h4><p>The app (also referred to as root) module is the entry point module. Because of this, you want to keep this to the bare essentials needed to <a href="https://angular.io/guide/bootstrapping#the-bootstrap-array">bootstrap</a> your app. In this module, you will bring in entry-level components and other app-level modules. See</p><h4>Core Module</h4><p>The core module is used to provide your singleton services and any high-level functionality. Any component, directive, or pipe that isn’t feature specific and is only used once in the app should end up in the core module. An example of this could be a navbar or footer component that is called once in your app component. This module should be imported once in the App module.</p><h4>Shared Module</h4><p>The shared module holds common UI components, directives, and pipes that are going to be used in many — if not every — feature module. This can include common Material UI modules, such as MatButtonModule or MatSelectModule. If you notice you are importing a module into every feature module, you should refactor it to live in the shared module instead.</p><h4>Feature Modules</h4><p>Feature modules will depend heavily on your application but ultimately this allows you to break up your app into small, single-purpose, chunks. In a feature module, you can import other modules, services, components, pipes, and directives that will be used in this feature.</p><h4>Routing Module</h4><p>The routing module is used when your application needs to have multiple <em>pages. </em>For example, a shopping app might need a route to /shopping-cart and /inventory. You can have multiple routing modules within your application, typically these will correlate to a feature module. This article won&#39;t go over routing modules in-depth — if you are curious to learn more <a href="https://angular.io/guide/router">start here</a>!</p><h3>Defining a Module</h3><p>You can define a module by importing NgModule decorator from @angular/core and passing a config with components, directives, pipes, and services that you want to use. Imagine we have a feature module called ShoppingCartModule — the module could look something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/57e573104cd38f38556f65edb1bd03ed/href">https://medium.com/media/57e573104cd38f38556f65edb1bd03ed/href</a></iframe><p>The config used above holds the most commonly used fields when defining a module. A more in-depth description of these fields can be found in <a href="https://github.com/angular/angular/blob/master/packages/core/src/metadata/ng_module.ts#L114">Angular’s source code</a>.</p><ul><li>delcarations : An array of components, pipes, and directives you want to make available to this module. This is scoped to the current module you are in.</li><li>imports : An array of other modules you will reference in this module</li><li>providers : An array of services that will only be used in this module. <em>Rember that services can be </em><a href="https://angular.io/guide/singleton-services"><em>singletons</em></a><em> and in that case, and should only be provided once in your app. If you need to use this service in multiple places feature modules, move it into the </em><em>core.module.ts .</em></li><li>exports : An array of components, directives, and pipes that you want to make available to the module this is imported to</li></ul><h3>Conclusion</h3><p>As you can gather, Angular modules are a fundamental building block to any Angular application. They are a great way to consolidate components, directives, services, and pipes into specific chunks of functionality within your application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c26d441e42fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>