<?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 Kelvin Yan on Medium]]></title>
        <description><![CDATA[Stories by Kelvin Yan on Medium]]></description>
        <link>https://medium.com/@kelvinyan?source=rss-a84c72ff2886------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nGpdWTwdOIV6DKJTQLOoRg.jpeg</url>
            <title>Stories by Kelvin Yan on Medium</title>
            <link>https://medium.com/@kelvinyan?source=rss-a84c72ff2886------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 15:39:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kelvinyan/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[An Overview of Modern Web Application Frameworks]]></title>
            <link>https://medium.com/@kelvinyan/an-overview-of-modern-web-application-frameworks-b5b8d105fe96?source=rss-a84c72ff2886------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5b8d105fe96</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[single-page-applications]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[business-technology]]></category>
            <category><![CDATA[framework]]></category>
            <dc:creator><![CDATA[Kelvin Yan]]></dc:creator>
            <pubDate>Wed, 10 Apr 2019 06:38:22 GMT</pubDate>
            <atom:updated>2019-08-04T19:43:24.231Z</atom:updated>
            <content:encoded><![CDATA[<h4>Multi-page application, single-page application, and other design choices</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8CdZNMqXAD-fPYJT" /><figcaption>Photo by <a href="https://unsplash.com/@kmuza?utm_source=medium&amp;utm_medium=referral">Carlos Muza</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>Web technologies evolve fast.</em></p><p>Web applications, referred to as <em>web apps</em> for short, play a crucial role for businesses in today’s hyper-competitive world. Companies should strive to make users love using their products and services. Web apps give dynamic user experiences.</p><p>Web application frameworks work to simplify development of web applications. They provide core functionality to work from so applications do not need to be built from the ground up. They help companies <strong>save time</strong> and <strong>reduce costs</strong>. They are easy to customize and output pages with dynamic content.</p><h4>What exactly is a web application?</h4><p>Sometimes it is difficult to distinguish between a website and a web application. Not every URL can be clearly classified as one or the other. To put it simply, <em>a website is intended for display purpose only.</em> A web application is <strong>also</strong> a website, yet it allows its user to do much more — such as to take input and do computation, allow you to edit an image, or send a message to another user; <em>Web applications are defined by its interaction with the user.</em></p><p>People enjoy using web apps because they are customer ready and do not need extra software installation — only a web browser. This is especially important for them before they have even decided on which app to use.</p><h4>Need for web applications</h4><p>Businesses use the Internet to broadcast their brand name, products, and services to the world. They constantly launch and update new web products because the Internet is growing at an amazing rate year after year.</p><p>While determined to keep up with new and upcoming trends and competing to win over customers, there is always a drive to expand their e-commerce and cloud service functionalities.</p><p>As changing demands fueled the need for new features that make it effortless for customers to enjoy, <strong>websites grew in complexity to meet these challenges.</strong></p><p>First-movers such as eBay and Amazon succeeded not only because they had strong marketing teams. Other companies had strong marketing teams too. They capitalized on the fast-evolving market with <strong><em>highly functional web applications</em></strong>.</p><p>They took simple concepts, such as purchasing, inventory, and transactions, and created scalable web marketplaces that are so dominant today.</p><p>Web applications that served different needs, such as Hotmail or Gmail cloud email services, leveraged the web browser capabilities to create email applications that did not require software installations. This portability is one reason they have grown into what they are today.</p><p>User authentication, profiles, real-time data tracking, messaging, online payments, app state — these are some ubiquitous features you see today. It is harder to release a successful web app if it is lacking in too many features that other web apps commonly have.</p><p>It is important to focus on the core features and functionality when developing a web app, but it is not enough to simply focus on those core things. An equal amount of effort should be spent on other features to complement the core functionality to make users love your product.</p><p>Web application frameworks continue to gain in popularity as new companies enter and create applications of their own to grab market share. Frameworks provide a base for much of the core functionality that every web application requires.</p><p>Almost all new web applications use at least one framework to simplify development and to keep up with change.</p><h4>Framework types</h4><p>There are many programming frameworks available to develop web applications from — several are listed in the sections below. They are divided into 2 main types: <strong>Multi-page applications</strong> (MPAs) and <strong>single-page applications</strong> (SPAs).</p><p>Multi-page applications came first and employed traditional programming languages such as PHP, .NET, and Java. MPAs are applications that run on a server and can communicate directly to databases.</p><p>Single-page applications gained traction when cross-browser JavaScript support improved. This also happened around when the usage of a popular browser plug-in, Adobe Flash, lost favor and died down. Unlike MPAs that live on the server, SPAs are downloaded to the client browser a single time and the page does not need to reload again. With a SPA, you still need a back-end server to provide content from APIs, but there is greater separation between both layers. The front-end view layer and the back-end server layer can each be swapped out without affecting the other so long as they both use the same API contracts.</p><h4>How to choose MPA or SPA</h4><p>MPA and SPA each serve to provide solutions to complex problems. One of the key advantages a SPA has is <strong>giving the user a faster and smoother experience.</strong> On the other hand, an advantage for MPA is that <strong>optimizing for SEO is easier</strong> and you can deal with <strong>application state on the server</strong>.</p><blockquote><strong>MPA</strong></blockquote><blockquote><em>A typical MPA serves a brand-new page on each route change and every change in data. Back when JavaScript support was not as ubiquitous and cross-platform, MPA was often preferable. Older computers did not have the same processing power as they have now, so it made more sense to process on the server. MPA generates fully ready to render HTML pages from the server</em>*<em>. The browser only has to receive the HTML mark up and then draw the page for the user.</em></blockquote><p>* this is a somewhat generalization as MPAs can also use JavaScript to dynamically render certain portions of the page.</p><blockquote><strong>SPA</strong></blockquote><blockquote><em>With a typical SPA, an empty shell of the application is delivered to the client on the first request, along with JavaScript files which initialize the application in the browser. The client’s device then fetches data from API endpoints to populate content inside the application as the user interacts with it. This allows them to be far more efficient and consume less data when compared to an MPA which generates a full page on each action. SPAs use built-in web browser functionality that allow unbroken transitions as the user navigates the web app. This way, clicking on links and buttons feels more like an application than a web site.</em></blockquote><p>If speed and smoothness is imperative for the application, using a <a href="https://medium.com/@kelvinyan/an-overview-of-modern-web-application-frameworks-b5b8d105fe96#60bb">SPA framework</a> would be the obvious choice.</p><p>If search engine indexability (SEO) is more important, then development and operational complexity will be reduced through the use of an MPA. This is because a SPA is only served with an empty HTML app shell — it requires the web crawlers to do some lifting and execute JavaScript files to determine what the content on the page is. Not only is this cumbersome for crawlers, it increases the time taken to render the page which may, at least with Google Search, impact your index rankings. We go more in depth on how to solve <a href="https://medium.com/@kelvinyan/an-overview-of-modern-web-application-frameworks-b5b8d105fe96#1155">SPA indexability issues</a> later.</p><h4>Single-page applications are everywhere</h4><p>Web applications have become necessary for companies to win customers, and single page applications provide the smooth experience that gives a competitive edge with getting users to stick to their product.</p><p>SPAs are developed in JavaScript or one of its supersets. MPAs use back-end languages (such as PHP, .NET, Java, or Python).</p><p>SPAs are modern and are an ideal choice for internal company applications and customer facing sites. Common websites such as Twitter and Facebook use SPA.</p><p>Some examples of SPAs which contain complex interactivity include G Suite, Microsoft Office 365, Azure, and Digital Ocean.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*XbbGLznN0TDy8JC8m4zOrw.jpeg" /><figcaption>Modern single page application frameworks</figcaption></figure><p>The most popular SPA frameworks right now are <a href="https://angular.io/">Angular</a>, <a href="https://reactjs.org/">React</a>, and <a href="https://vuejs.org/">Vue</a>. Other SPAs include <a href="https://emberjs.com/">Ember</a> and <a href="https://www.meteor.com/">Meteor</a>. There is no clear winner for which SPA framework is better, but important factors include design of the system and developer comfort and experience with the framework.</p><h4>Are SPAs fitting for your web application?</h4><p>SPAs are great because they will seem faster for the user. Sometimes though, there are drawbacks to using this modern web app type. Here are reasons why it may or may not be the right fit.</p><p>Why a SPA is a good fit:</p><ul><li>Gives an experience similar to a desktop or mobile app</li><li>Creates greater separation of the back-end layer and the view layer</li><li>Building data endpoints instead of server-generated pages allows greater flexibility and reusability</li><li>Your data can be consumed by different applications where re-using API endpoints would make better sense</li><li>After the initial load and start up, everything is fast</li><li>Scales better because of the lighter load on web servers</li><li>SPAs can be ported into hybrid native mobile apps</li></ul><p>Why a SPA might not be the best fit:</p><ul><li>SEO is important</li><li>MPAs will usually have a view-templating system built into the framework that can be easier to develop with</li><li>Your web application is simple and only has a small set of functions</li><li>Large SPAs can often be more complex to build</li></ul><h4>Hybrid apps</h4><p>Sometimes there will be certain modules or areas of an application that can be separated. A hybrid mix of SPA and MPA can be made to work in tandem using web server redirection.</p><p>Alternatively, SPA and/or MPA can be mixed with static web pages. Static web pages will always load faster than their counterparts. They are a good choice on pages which only provide information and do not change often (i.e. info and blog pages).</p><h4>Solving SPA indexability</h4><p>Some SPAs deploy an additional engine to deal with SEO related issues. They call this feature <strong>server-side rendering</strong> (SSR). Server-side renderers are <em>middleware</em> that draw content into the app shell before the HTML markup is sent to the client. By default, SSR are added features and are not built into the frameworks. Implementing SSR will always increase the complexity of your application.</p><p>SSRs can sometimes be fickle. A small example based on personal discovery — a SSR for the Angular framework (Angular Universal) does not pre-render certain meta tags such as Open Graph that might be very important to your app. This would affect how WhatsApp previews would look like to users sharing app pages to their friends.</p><blockquote><em>SSR can work for you, but usually contains quirks and requires additional effort to optimize for.</em></blockquote><p>That being said, some amazing services such as <a href="https://prerender.io/">Prerender</a> and <a href="https://render-tron.appspot.com/">Rendertron</a> solve this problem, even the WhatsApp previews. These services act as a caching proxy (they serve rendered content rather than just the app shell) that facilitate web crawlers and previewers to understand the content. This also can improve technical SEO for SPA pages because they are cached and do not need to wait for the SSR to do work on each request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*k1HEK8aKMukNlhBt7_3Y3w.jpeg" /><figcaption>Modern multi-page application frameworks</figcaption></figure><h4>Many MPA frameworks to choose from</h4><p>Common MPA frameworks include <a href="https://spring.io/">Java Spring</a>, <a href="https://www.djangoproject.com/">Python Django</a>, <a href="https://docs.microsoft.com/en-us/aspnet/">ASP.NET MVC/Razor</a>, and <a href="https://laravel.com/">PHP Laravel</a>. When not serving pages, they can also act as the API back-ends for SPA frameworks to consume.</p><h4>Hybrid MPA and SPA</h4><p>There is no single best solution where you might build the entire site with a single framework. Oftentimes, <em>and if resources are available</em>, a hybrid approach of SPA and MPA and/or static pages works best if the web application can be divided up. Both choices, whether it be a SPA or MPA, will work for the company. The differences are in the implementation details and user experience.</p><p>It may sometimes be more complex to build a SPA, although any large application will undoubtedly be complex anyway.</p><h4>Do you need a SPA or an MPA? Which one is better?</h4><p>If you want your web app to function similar to a desktop or mobile app, have fast navigation between pages, have seamless transitions, then it would be a great idea to implement a SPA.</p><p>On the other hand, if you require a database but there are few interactions between your user and the application, then it may be easier to develop and deploy using a MPA.</p><p>Most companies have adopted SPAs or are in the process of converting their web app to a SPA because companies want to build the <strong>best product</strong> and provide the <strong>best user experience</strong> that will make customers stick with them.</p><p>In 2019 the overall experience for users is that <em>web apps are noticeably faster than in the past</em>. It is <strong>uncommon</strong> now to see large enterprises or startups build their web applications as a MPA.</p><blockquote><strong>Native apps</strong></blockquote><blockquote><em>As an aside, there exist many native apps that provide next to no additional functionality over a web app except being able to have a shortcut icon on a device. If you are thinking about developing a native app, you should also consider whether or not a web app would suffice. A web app will never match the full range of capabilities that a native app has and will not be able to use the full screen pixel dimensions of the device, but it will allow for simpler cross-compatibility between all devices. Furthermore, some users may look elsewhere if they need to download and install an app to try it.</em></blockquote><p><em>Originally published at </em><a href="https://bravoka.io/articles/modern-web-application-frameworks/"><em>bravoka.io</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5b8d105fe96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Validate AMP Pages]]></title>
            <link>https://medium.com/@kelvinyan/how-to-validate-amp-pages-f1b4a38224c9?source=rss-a84c72ff2886------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1b4a38224c9</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[amphtml]]></category>
            <category><![CDATA[validation]]></category>
            <category><![CDATA[amp]]></category>
            <dc:creator><![CDATA[Kelvin Yan]]></dc:creator>
            <pubDate>Mon, 10 Dec 2018 12:02:59 GMT</pubDate>
            <atom:updated>2018-12-10T12:04:49.318Z</atom:updated>
            <content:encoded><![CDATA[<h4>It’s easy and straightforward to validate your pages and eliminate any errors.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8-EESdGJ8FY5hkjaZgY_1Q.jpeg" /><figcaption>Photo by Preston Goff (Unsplash)</figcaption></figure><h3>Why is AMP validation important?</h3><p>When I first started building AMP sites, I received alerts every now and then from Google Search Console informing me that some pages contained invalid AMP structure.</p><p>Since then, I have incorporated validation into the workflow, so the process is error-free.</p><p>An invalid AMP page can be easy to miss. Google Search Console will alert you about the problems, but sometimes that can take several days for it to happen. During this time, the page shown in search results will not have the gray ⚡ symbol nor will it be served through Google’s CDN.</p><p>Validating AMP pages is not hard. There are numerous techniques to <em>check them yourself manually</em> or to <em>automate validation to detect problems early</em>.</p><p>Even if there are only a small handful of pages, ensuring that all of them are valid <strong>should be a continuous part of your build process</strong> before deploying your website for the first time, as well as for any subsequent changes made to it.</p><p>Listed below are different ways on how AMP validation can be achieved either manually, or through scripts and automation.</p><h3>6 ways to validate AMP pages:</h3><ol><li>Install a Browser Plugin</li><li>Validator (Automation)</li><li>Gulp Validator (Automation)</li><li>AMP Project Validator (Web App)</li><li>Google Search Console Validator (Web App)</li><li>Inspector / Dev Tools</li></ol><h4>1. Install a Browser Plugin</h4><p><em>(currently only available for Chrome and Opera)</em></p><p>Download and install the <a href="https://chrome.google.com/webstore/detail/amp-validator/nmoffdblmcmgeicmolmhobpoocbbmknc">Chrome Plugin</a> or the <a href="https://addons.opera.com/en-gb/extensions/details/amp-validator/">Opera Plugin</a>.</p><p>This plugin provides a visual confirmation of the AMP structure’s validity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ko2QnFyqtfJGmYk-7txcCw.png" /><figcaption>Blue AMP icon showing that an AMP link is available. Clicking the icon will navigate you to the AMP page link.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lv14h358RqVPw0mmEAmatQ.png" /><figcaption>Green AMP icon representing valid AMP — no problems here.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HQIg7mslSo232oOjfFW3Hw.png" /><figcaption>Red AMP icon representing invalid AMP with one error. Clicking the icon will show additional details about that error.</figcaption></figure><h4>2. Validator (Automation)</h4><blockquote>The <a href="https://www.npmjs.com/package/amphtml-validator">amphtml-validator</a> is a versatile package used to integrate AMP validation into any project.</blockquote><p><strong>1) Continuous Integration Setup</strong></p><blockquote><em>The example below is a CI script setup for my own projects using </em><a href="https://gohugo.io/"><em>Hugo</em></a><em>, a static site generator. We’ll need to install the npm package to our project:</em></blockquote><p>npm install amphtml-validator --save-dev</p><p>Next, edit the <strong>package.json</strong> file to add to the script.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e536d06810264e9da3d53b4e3e3b5974/href">https://medium.com/media/e536d06810264e9da3d53b4e3e3b5974/href</a></iframe><blockquote><em>AMP is validated and shown in console output when building the project using </em><em>npm run build:prod.</em></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e50a867b3b5df50911aaee4574a2543f/href">https://medium.com/media/e50a867b3b5df50911aaee4574a2543f/href</a></iframe><p><strong>2) Command Line Setup</strong></p><blockquote>Instead of writing scripts attached directly to the project, one can opt to install amphtml-validator for command line usage instead.</blockquote><blockquote><em>We’ll need to install the package with the global flag:</em></blockquote><p>npm install -g amphtml-validator</p><p>A Bash and a PowerShell example are shown below.</p><ul><li><strong>Bash Example</strong></li></ul><blockquote><em>A Bash sample script to validate your AMP pages in folders recursively:</em></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9791df38f7b04907000385ac009299ef/href">https://medium.com/media/9791df38f7b04907000385ac009299ef/href</a></iframe><blockquote><em>On a troubleshooting side note </em><strong><em>for Macs</em></strong><em>, if you receive a message on your Terminal saying </em>it does not recognize the <em>amphtml-validator</em> command<em>, try out the following solution:</em></blockquote><p>nano ~/.bash_profile to add an alias.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1dbc30f16b71e571b29bbb4f4713ca15/href">https://medium.com/media/1dbc30f16b71e571b29bbb4f4713ca15/href</a></iframe><ul><li><strong>PowerShell Example</strong></li></ul><blockquote><em>A PowerShell sample script to validate your AMP pages in folders recursively:</em></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/135c8486b9468016796299723a487897/href">https://medium.com/media/135c8486b9468016796299723a487897/href</a></iframe><h4>3. Gulp Validator (Automation)</h4><blockquote><em>For Gulp projects, you can choose to use </em><a href="https://www.npmjs.com/package/gulp-amphtml-validator"><em>gulp-amphtml-validator</em></a><em> package for easy integration.</em></blockquote><p>npm install gulp-amphtml-validator --save-dev</p><blockquote><em>An example of how your gulp task might look:</em></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/901ec3b23525a18175f6476be63ddec0/href">https://medium.com/media/901ec3b23525a18175f6476be63ddec0/href</a></iframe><blockquote><em>Manually run AMP validation with </em><em>gulp amphtml:validate</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dnOIlFiZpFQxLBum6XlojQ.jpeg" /><figcaption>Example output from the Gulp validator on invalid AMP.</figcaption></figure><h4>4. The AMP Project Validator (Web App)</h4><blockquote>The <a href="https://validator.ampproject.org/">AMP Validator</a> is a sandbox to validate your AMP code. Additionally, it can also validate external URLs. Enter an AMP URL to test:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WKsOc_CGIUv6bnZzOQiQog.png" /><figcaption>The AMP Validator</figcaption></figure><h4>5. Google Search Console Validator (Web App)</h4><blockquote>The <a href="https://search.google.com/test/amp">Google AMP Testing Tool</a> can also be used to validate external URLs. Again, enter any AMP URL to test:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qn6tcCUSstVMxvhwxFYgyQ.png" /><figcaption>Google Testing Tool</figcaption></figure><p><em>Furthermore, the Google Testing Tool also includes a </em><strong><em>Preview Search Result</em></strong><em> function to see how the page will look like with the AMP header.</em></p><h4>6. Inspector / Dev tools (in any browser)</h4><p>Lastly, you can use your browser’s dev tools and view console output. Append <strong>#development=1</strong> to the end of your URL to make AMP display validation logs verbosely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*0V0pnoYgAeu7dlRTa6n3sw.jpeg" /><figcaption>Console output showing one validation error. These logs only appear when the special hash value is appended at the end of the URL.</figcaption></figure><p><em>It’s very rare that you may find this method convenient to use unless you do not have Chrome or Opera available.</em></p><h3>How will invalid AMP code affect SEO?</h3><p>If invalid AMP pages are deployed by mistake, <em>those pages will still appear in Google search results</em>.</p><p>Through our tests, if an invalid AMP page is also the canonical version, that page will still be indexed by Google.</p><p>In both situations, however, the pages will not receive any of AMP’s benefits.</p><p>Of course, not having to worry about AMP + SEO issues is the best goal to have by ensuring valid AMP pages every time.</p><p><em>Originally published at </em><a href="https://bravoka.io/articles/how-to-validate-amp-pages/"><em>bravoka.io</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1b4a38224c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Future of Accelerated Mobile Pages (Google AMP) in 2019]]></title>
            <link>https://medium.com/@kelvinyan/future-of-accelerated-mobile-pages-google-amp-in-2019-d5023810eb58?source=rss-a84c72ff2886------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5023810eb58</guid>
            <category><![CDATA[website]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[amp]]></category>
            <category><![CDATA[accelerated-mobile-pages]]></category>
            <dc:creator><![CDATA[Kelvin Yan]]></dc:creator>
            <pubDate>Thu, 29 Nov 2018 06:32:24 GMT</pubDate>
            <atom:updated>2018-12-12T10:52:11.833Z</atom:updated>
            <content:encoded><![CDATA[<h4>In a growing effort to provide better user experiences, Google continually encourages websites to adopt their open source library and standards – AMP. Google strongly cares about fast page load times and AMP is a solution to make it happen.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QAHVk3TYG4vcVAWHOUC38Q.jpeg" /><figcaption>Photo by Yasmin Dangor (Unsplash)</figcaption></figure><h3>AMP in 2019</h3><p>We are 2 months away from 2019. Looking at search results, most sites <em>still have not</em> implemented AMP.</p><blockquote>Are there consequences to not having AMP <em>on a website?</em></blockquote><p>The short answer is <strong><em>yes</em></strong>.</p><p>Google AMP provides some perks that you would otherwise be missing out on. <strong>Many websites are already taking advantage of what AMP has to offer</strong>.</p><p>One of the reasons AMP makes a positive impact is it <strong>increases click through rate </strong>through its distinct appearance in Google SERP. Another reason is it lets visitors <strong>render pages quickly </strong>— especially useful if the pages have large resources to load.</p><p>AMP is not only used primarily by news publishers anymore. In the past few years, more and more blogs and businesses have begun AMP-ing their websites.</p><p>As the AMP logo ⚡ is associated with <strong>near instant load times</strong>, many publishers are quickly catching on to adopt AMP in order to increase their click through rates and decrease bounce rates.</p><p>For WordPress websites, AMP plugins have improved where they can be easily added and are usually good enough to convert the entire website to AMP.</p><h3>What is AMP?</h3><p>Released by Google in 2015, the <a href="https://en.wikipedia.org/wiki/Accelerated_Mobile_Pages">Accelerated Mobile Pages Project</a> are a standard set of libraries that enforce publishers to follow a set of <em>opinionated best practices</em>.</p><p>One of the design principles of AMP is to <em>“only do things if they can be made fast”</em>. These libraries are optimized to load your site with very few compromises on speed in order to <strong>prioritize the user experience</strong>.</p><p>This means it handles an amazing set of built in features such as <strong>scripts loaded asynchronously</strong>, <strong>lazy loading</strong> images and components as you scroll, and utilizing a <strong>global CDN cache</strong> to serve your webpages.</p><p>Rather than relying on a single all-inclusive library, AMP ensures its components are extensible. The most commonly used core components are found in the main library. Everything else is put into their own AMP component, where they are explicitly declared in the head whenever used on the corresponding pages. The result is <strong>less bytes for users to download</strong> and <strong>fast page rendering</strong>.</p><p>For developers, AMP could be considered as a type of JavaScript framework. The AMP project decided that controls, such as preventing custom JavaScript from running and third-party libraries from being loaded, were necessary to make sites fast, simple, and reliable.</p><p>You certainly can still build a site that is optimized for speed without using AMP, but Google views valid AMP integration as a <strong>trust factor</strong> that a page will load hastily.</p><p>AMP-ing your site is entirely <em>optional</em>, but by following their standards and building an AMP version, Google rewards participating publishers by attaching a <strong>small grey lightning bolt icon</strong> in mobile search results — often leading to higher SERP click rates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*2iKGjI86MoXyM6t5ntLShg.png" /><figcaption>Example mobile search results with AMP implementations are shown above.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*vLJbHn-WIeydgmalXTumgA.png" /><figcaption>Example mobile search results for an AMP Story are shown above. AMP Stories also include a carousel icon.</figcaption></figure><p>Not only do pages receive <em>“whatzit” </em>icons (more on this later)<em> </em>for <strong>valid AMP structure</strong>, the pages indexed will also be served through the super-fast Google CDN.</p><p>Since popular websites are now utilizing AMP, most devices will already have the standard AMP libraries cached in their browser. This further reduces the time it takes between a user clicking on a search result and being able to see the content.</p><blockquote>AMP was primarily designed to <em>improve the mobile user experience</em>. Thus far, AMP pages are only served on a mobile device. For tablet and desktop search results, only the canonical versions are returned.</blockquote><p>As a technical side-note, you could use your AMP page as the canonical version by having a single responsive AMP version of each page for both desktop and mobile, and <em>Google even encourages this</em>.</p><h3>What are the limitations to AMP?</h3><p>In order to comply with valid AMP structure, you cannot run your own JavaScript nor load external libraries. For many developers, this reason alone is enough to shy away from AMP.</p><p>However, AMP intended for developers and creators to use the various AMP components to accomplish things rather than by accomplishing them through JavaScript. When paired with state management components, such as provided by <a href="https://www.ampproject.org/docs/reference/components/amp-bind">amp-bind</a>, there is <strong>enormous flexibility on what you can still do</strong>.</p><h3>Can I use AMP if the content on my site is dynamically generated?</h3><p>Indeed, if your website fetches data from an API to populate content, this can still be achieved even without JavaScript.</p><p><a href="https://www.ampproject.org/docs/reference/components/amp-list">Amp-list</a> was designed for this in mind. It consumes JSON data and adds DOM elements to the page (usually used together with <a href="https://www.ampproject.org/docs/reference/components/amp-mustache">amp-mustache</a>).</p><p>AMP is also <a href="https://www.ampproject.org/support/faqs/supported-platforms">supported by many popular platforms that each have their own components</a> such as Reddit, Twitter, Instagram, YouTube, and ad networks just to name a few. Integrating these components onto your page is non-trivial work.</p><h3>What gives AMP a bad reputation among some in the web community?</h3><p>Whether or not AMP is good for the future of the web is a hotly debated topic. The reasons people <strong>argue against</strong> adopting AMP are usually:</p><ul><li>a standard AMP site can be more complex to build, especially when many useful open source libraries are unavailable.</li><li>sites will all start to look the same.</li><li>a <em>search engine monopoly</em> enforcing web standards is <em>not a good thing</em>. Giving advantages to those who adopt the standards will, over time, force people to build sites <em>“the Google way”</em> just to get ranked.</li></ul><h3>9 Reasons Why You Should Implement AMP</h3><h4>1. Page Speed</h4><p>Improving the page load speed for your user. Users will appreciate fast loading sites, especially when they are on <em>slower mobile connection speeds</em>.</p><h4>2. Responsive</h4><p>AMP components already have responsive design in mind.</p><h4>3. Mobile-first user experience</h4><p>As mobile use increases, companies will be scrutinizing their mobile / AMP page more carefully to <em>optimize for conversions</em>.</p><h4>4. AMP components</h4><p>There is a long list of components available to use <em>without having to worry about implementation details</em>.</p><h4>5. Fast growing</h4><p>AMP is <a href="https://www.ampproject.org/roadmap/">constantly growing and improving its features</a> with emphasis on speed.</p><h4>6. AMP Stories</h4><p>Similar to Instagram Stories, an <a href="https://www.ampproject.org/stories/">AMP Story</a> is a unique format twist to view content.</p><h4>7. <em>“Whatzit”</em></h4><p>The AMP ⚡ icon in Google mobile results provides a kind of <em>“whatzit”</em> — a term coined by Leil Lowdnes in her book <em>How to Talk to Anyone</em>. The basic premise of a <em>“whatzit”</em> is to <strong>entice curiosity</strong>. Suppose that a user sees several different article pages, and one of them has the AMP ⚡ icon. The one with the icon will catch their eye, maybe interest them, and naturally increases the likelihood that they will read the title and description — subsequently <strong><em>increasing the chances of a user’s initial visit</em></strong>.</p><h4>8. Bing</h4><p>Even Bing is <a href="https://blogs.bing.com/Webmaster-Blog/September-2018/Introducing-Bing-AMP-viewer-and-Bing-AMP-cache">adopting AMP</a>.</p><h4>9. Auto Validation</h4><p>AMP validation is built right into the web — Google will let you know if your page is invalid during index time, but <a href="https://medium.com/@kelvinyan/how-to-validate-amp-pages-f1b4a38224c9">there are many other free tools to validate them yourselves before that occurs</a>.</p><h3>9 Reasons Against the Use of AMP</h3><h4>1. There is nothing wrong with non-AMP pages</h4><p>You can build fast and beautiful sites without AMP — we have been doing so for <em>decades</em>!</p><h4>2. You receive high traffic volume</h4><p>Your site <em>already ranks well</em> and implementing AMP may provide little benefits.</p><h4>3. Website already loads fast</h4><p>You built a <em>lean website</em> using best practices.</p><h4>4. You require a specific plugin or library</h4><p>While AMP components contain the most widely used features, it may not contain that <em>custom JS library necessary</em> for your page.</p><h4>5. Web development</h4><p>If you want a specific look on your AMP page, a theme may not be available. You may just have to design it yourself, and if you have <em>limited experience with CSS/HTML</em>, then chances are that your site will look much cleaner and cross-compatible using a CSS/JS library.</p><h4>6. Maintaining two codebases</h4><p>Idealistically, no one wants to maintain both a non-AMP <strong>and</strong> an AMP version of their site.</p><h4>7. Lack of control</h4><p>You may be a creative designer who needs <em>full access to the browser</em>, or you may be against being dictated on what libraries to use and what rules to adhere to. Losing custom JavaScript really limits many cool things you can do… although there are workarounds such as with <a href="https://www.ampproject.org/docs/reference/components/amp-iframe">amp-iframe</a>.</p><h4>8. Authoritative trust</h4><p>Google is a public company interested in <em>revenue and profit</em>. Can we trust Google not to leverage AMP for its own self interests in the future?</p><h4>9. Web application</h4><p>AMP is not in any way designed to be used with web applications.</p><h3>Does AMP Increase My Google Rankings?</h3><p>While it certainly will not decrease your rankings, Google has stated before that AMP is still not a ranking factor.</p><h3>🍌 John 🍌 on Twitter</h3><p>@amro_d80 @googlewmc AMP isn&#39;t a ranking factor; if you decide to disable it, make sure to redirect appropriately.</p><p>Nevertheless, most SEO agencies have experienced positive results to their page rankings — incidentally through increased user engagement and faster response times after adopting AMP.</p><p>Over the years, Google has also repeated that page speed will increasingly become a contributing factor. This July, Google rolled out <a href="https://webmasters.googleblog.com/2018/01/using-page-speed-in-mobile-search.html">a search algorithm update that is based on page load speeds on mobile devices</a>. This update negatively impacted sites with load times exceeding a high threshold.</p><h3>Adoption</h3><p>Some large companies that have already adopted AMP are:</p><ul><li>New York Times</li><li>South China Morning Post</li><li>Wall Street Journal</li><li>USA Today</li><li>Yahoo</li><li>Reddit</li><li>BMW</li></ul><h3>Should I Implement AMP?</h3><blockquote>If you make every effort to follow Google guidelines, should Google reward you? <strong><em>Probably</em></strong>.</blockquote><p>However, there are countless ranking factors, and speed is just one of them.</p><p>If you have the <em>resources and time to implement AMP</em>, then yes, you probably should add it in, if you have not already.</p><p>Google keeps pushing new features into AMP, and there is no doubt that AMP will still be <em>thriving in the future</em>.</p><blockquote>With AMP, your site will still be <em>future-proof</em> if Google one day decides to increase AMP’s <em>ranking impact</em>.</blockquote><p>Every website is different however, and before doing anything, you should first analyze your website or business to see whether the time and effort will be worth it, and not just because everyone else is doing it.</p><p><em>Originally published at </em><a href="https://bravoka.io/articles/accelerated-mobile-pages-2019/"><em>bravoka.io</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5023810eb58" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning Angular Pipes — Part II]]></title>
            <link>https://medium.com/@kelvinyan/learning-angular-pipes-part-ii-89418573eb74?source=rss-a84c72ff2886------2</link>
            <guid isPermaLink="false">https://medium.com/p/89418573eb74</guid>
            <category><![CDATA[angular2]]></category>
            <dc:creator><![CDATA[Kelvin Yan]]></dc:creator>
            <pubDate>Wed, 21 Feb 2018 08:34:02 GMT</pubDate>
            <atom:updated>2018-03-16T13:54:21.502Z</atom:updated>
            <content:encoded><![CDATA[<p>Async Pipe. Pure vs Impure Pipes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g-kzenQN4pItnjYLHmk4WQ.jpeg" /></figure><h3>Async Pipes</h3><p>Unlike in <a href="https://medium.com/@kelvinyan85/learning-angular-pipes-part-i-66b483603792">part I</a> of Angular pipes, <em>async</em> does not format existing data. It only waits for data to be received.</p><p>In the below example, we have our data bound to an observable, and then wait 1 second for data to be received after we click the button.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f08207cf8d8069b27bed5ed59c39e19d/href">https://medium.com/media/f08207cf8d8069b27bed5ed59c39e19d/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/155/1*1XB82Fcd4a3uXETBuiESmw.png" /><figcaption>Instead of our expected result, we get [object Object]. Note: this would occur whether or not we have delay.</figcaption></figure><p>We know that data is received after 1 second, but we still need to <em>subscribe</em> to that data. When we use <em>async</em>, it subscribes automatically.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ab1cd93659ee7e7c9925546aa76b4dc/href">https://medium.com/media/7ab1cd93659ee7e7c9925546aa76b4dc/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/126/1*3biJ8RgvMf-gS2gSceN-dw.png" /><figcaption>After clicking, we now see the data as it appears after 1 second.</figcaption></figure><p>Advantages of using async include:</p><ol><li>Data can be an Observable rather than a Subscription.</li><li>It unsubscribes automatically when the component is destroyed (no memory leaks).</li><li>End up writing less code.</li></ol><h3>Pure vs Impure Pipes</h3><p>By default, all pipes are pure. You can make them impure by creating a custom pipe and setting the property pure to false. A<em>sync</em> is an example of an impure pipe. It is always checking for new input data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c0fb8d9455e85bf12675921221b5dcc/href">https://medium.com/media/3c0fb8d9455e85bf12675921221b5dcc/href</a></iframe><blockquote>The pure property tells Angular whether or not the value should be recomputed when its input changes.</blockquote><p>When the pipe is pure, it does not check the input to see whether or not to update the transformed data.</p><p>Pure defaults to true for good reasons. Sometimes there is no need to keep recalculating on every change detection. On a large list of items, it could cause performance issues.</p><p>Angular defaults this behaviour to true and lets the developer decide whether or not impure is required.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89418573eb74" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning Angular Pipes — Part I]]></title>
            <link>https://medium.com/@kelvinyan/learning-angular-pipes-part-i-66b483603792?source=rss-a84c72ff2886------2</link>
            <guid isPermaLink="false">https://medium.com/p/66b483603792</guid>
            <category><![CDATA[angular2]]></category>
            <category><![CDATA[pipes]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Kelvin Yan]]></dc:creator>
            <pubDate>Sun, 18 Feb 2018 04:05:28 GMT</pubDate>
            <atom:updated>2018-03-16T13:52:40.819Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Whk-yk0yECGJb54x1qRUw.jpeg" /></figure><h4>Use pipes to create reusable data transformations.</h4><h4><strong>What do Angular pipes do and when should one use them?</strong></h4><p>Pipes are an Angular feature that allow you to transform output inside your template. They transform your data once they are rendered on your screen.</p><p>Sometimes data from APIs or some other source may need fine tuning to be viewed attractively. We would have to write functions to transform properties and values into something cleaner and more readable for the user. Alternatively, if the data was from your own backend, you <em>could</em> format the data coming from the API as well, <em>but</em> there may be a good reason already for your data to be returned the way it is.</p><blockquote><em>Angular Pipes give you the flexibility to transform data in the view without changing the actual data values themselves.</em></blockquote><p>Pipes are one of the tools to make that easy for the developer. It is one of the excellent features of the Angular framework because of its clean style and the data-view transformations are declared on the HTML template data-bindings. If this seems useful to you, continue reading on to see how you can easily integrate pipes in your Angular projects.</p><p>Using pipes should be familiar to most developers as they are used often in Linux scripting and PowerShell.</p><blockquote>Use Angular pipes by declaring the variable, followed by the pipe symbol “|” inside the HTML template.</blockquote><blockquote>Example syntax for adding a pipe: {{ myVariable | pipeName }}</blockquote><p>There can be multiple pipes in a template and you can also chain pipes together. The Angular Framework provides several pipes already, but you can create custom pipes as well.</p><p>The use of pipes is to keep raw data <em>separate</em> from view data so that we only transform the viewed data as we need it.</p><p>The tutorial below shows examples in how to use Angular pipes. I assume you have some basic experience with Angular, so certain aspects of the code are not discussed in depth, such as ngFor and FormsModule. There is a introductory tutorial that is highly recommended, <a href="https://angular.io/docs">Tour of Heroes</a>, to get you get started on Angular.</p><h3><strong>Tutorial — Purrfect Delivery Company</strong></h3><p>Imagine we are requesting data from an external pet store API, which calls a database and returns a list of kittens that are available for sale, as well as some additional details about each kitten.</p><p>To simplify the tutorial so that we can focus on pipes and the view, we will just hard code the data and assume it is being returned from an actual API.</p><p>Here is our JSON data that we receive from this pet store API.</p><pre>{<br>  &quot;kittens&quot;: [{<br>      &quot;breed&quot;: &quot;tabby&quot;,<br>      &quot;name&quot;: &quot;zeus&quot;,<br>      &quot;birthdate&quot;: &quot;2016-07-09&quot;,<br>      &quot;price&quot;: 50<br>    },<br>    {<br>      &quot;breed&quot;: &quot;sphinx&quot;,<br>      &quot;name&quot;: &quot;charles&quot;,<br>      &quot;birthdate&quot;: &quot;2017-08-05&quot;,<br>      &quot;price&quot;: 200<br>    }<br>  ] <br>}</pre><p>Now we use this JSON object to create a list for our kittens app in the template.</p><pre>&lt;h1&gt;<br>  Kittens<br>&lt;/h1&gt;<br>&lt;div *ngFor=&quot;let kitten of petStoreData.Kittens&quot;&gt;<br>  &lt;ul&gt;&lt;label&gt;Breed:&lt;/label&gt; {{ kitten.breed }}&lt;/ul&gt;<br>  &lt;ul&gt;&lt;label&gt;Name:&lt;/label&gt; {{ kitten.name }}&lt;/ul&gt;<br>  &lt;ul&gt;&lt;label&gt;Birthdate:&lt;/label&gt; {{ kitten.birthdate }}&lt;/ul&gt;<br>  &lt;ul&gt;&lt;label&gt;Price:&lt;/label&gt; {{ kitten.price }}&lt;/ul&gt;<br>&lt;/div&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*op-0alO8TcPUXAVKeYLB0Q.png" /><figcaption>Our kitten list viewed with raw data from the API.</figcaption></figure><p>Although this is satisfactory, we could improve the data being viewed in 4 ways:</p><ol><li>Breed is important to customers who are shopping our site so we should emphasize it by making it uppercase.</li><li>Kitten’s name should have its first letter capitalized.</li><li>Let’s convert the date of birth to age in months.</li><li>Let’s add in currency conversion functionality for our global customers.</li></ol><p>Starting off, Angular includes some pipes already built into the framework. Here we can use Angular’s <em>UpperCasePipe</em>. . The list of featured pipes can be found <a href="https://angular.io/api?query=pipe">here</a>.</p><pre>&lt;h1&gt;<br>  Kittens<br>&lt;/h1&gt;<br>&lt;div *ngFor=&quot;let kitten of petStoreData.Kittens&quot;&gt;<br>  &lt;ul&gt;&lt;label&gt;Breed:&lt;/label&gt; {{ kitten.breed <strong>| uppercase</strong> }}&lt;/ul&gt;<br>  &lt;ul&gt;&lt;label&gt;Name:&lt;/label&gt; {{ kitten.name }}&lt;/ul&gt;<br>  &lt;ul&gt;&lt;label&gt;Birthdate:&lt;/label&gt; {{ kitten.birthdate }}&lt;/ul&gt;<br>  &lt;ul&gt;&lt;label&gt;Price:&lt;/label&gt; {{ kitten.price }}&lt;/ul&gt;<br>&lt;/div&gt;</pre><p>We use the pipe symbol “|” followed by <em>uppercase</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*WWYcnFT1-GHj9FFMKNjRJQ.png" /><figcaption>Implementing this pre-built pipe was easy. We did not even have to import anything.</figcaption></figure><p>There is no pipe in Angular to capitalize words, so we next will write a custom one.</p><p>To easily set up the template for a new custom pipe, using Angular CLI type:</p><p>ng generate pipe capitalize</p><blockquote>This command created a file named <em>capitalize.pipe.ts</em> for us. Additionally, it added the import statement and declaration inside your <em>app.module.ts</em> file.</blockquote><p>Alternatively, you could have created the file manually and added the declaration yourself, but the Angular CLI makes it easy by creating the template for everything we need.</p><p>Next, open up the <em>capitalize.pipe.ts</em> file, and modify the transform method to be the same as the one below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*Brem_3U-upMpU4g6vqxhEg.png" /><figcaption>Transform is where you insert the logic for how to output the data.</figcaption></figure><p>This file contains the @Pipe decorator, which we set the key value ‘<em>name</em>’ to ‘<em>capitalize</em>’. Later, we can use {{ data| capitalize }} in our html template.</p><blockquote>The class implements <strong>PipeTransform</strong> which is an interface that contains the method <strong><em>transform</em></strong>.</blockquote><pre>&lt;h1&gt;<br>  Kittens<br>&lt;/h1&gt;<br>&lt;div *ngFor=&quot;let kitten of petStoreData.Kittens&quot;&gt;<br>  &lt;ul&gt;&lt;label&gt;Breed:&lt;/label&gt; {{ kitten.breed | uppercase }}&lt;/ul&gt;<br>  &lt;ul&gt;&lt;label&gt;Name:&lt;/label&gt; {{ kitten.name <strong>| capitalize</strong> }}&lt;/ul&gt;<br>  &lt;ul&gt;&lt;label&gt;Birthdate:&lt;/label&gt; {{ kitten.birthdate }}&lt;/ul&gt;<br>  &lt;ul&gt;&lt;label&gt;Price:&lt;/label&gt; {{ kitten.price }}&lt;/ul&gt;<br>&lt;/div&gt;</pre><p>Once we have created the custom pipe, we can declare it in our template.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*tPRD3_SSwvLuCZ3ZPMnL0g.png" /><figcaption>Again, we just use the pipe to transform the data, which now capitalizes their names.</figcaption></figure><p>It would be nice to have the kitten’s ages in months, rather than their date of birth. Again let’s generate another custom pipe through Angular CLI.</p><p>ng generate pipe ConvertToMonths</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*oKG8vdtqAMMx0VblypM8RA.png" /><figcaption>Here is a simple implementation of a pipe that converts a Date object to number of months.</figcaption></figure><p>We implement our new pipe in our template again, this time changing the label “<em>birthdate”</em> to “<em>age”</em>.</p><pre>&lt;h1&gt;<br>  Kittens<br>&lt;/h1&gt;<br>&lt;div *ngFor=&quot;let kitten of petStoreData.Kittens&quot;&gt;<br>  &lt;ul&gt;Breed: {{ kitten.breed | uppercase }}&lt;/ul&gt;<br>  &lt;ul&gt;Name: {{ kitten.name | capitalize }}&lt;/ul&gt;<br>  &lt;ul&gt;<strong>Age</strong>: {{ kitten.birthdate <strong>| convertToMonths</strong> }}&lt;/ul&gt;<br>  &lt;ul&gt;Price: {{ kitten.price }}&lt;/ul&gt;<br>&lt;/div&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/197/1*traR67VlfWxLvvh7E9JuPQ.png" /><figcaption>Now customers can do less math in their head.</figcaption></figure><p>Lastly, for the currency conversion functionality, we will chain two pipes together. We will utilize Angular’s built in <em>CurrencyPipe</em> which returns the currency symbol pre-pended to the value, and chain it to the converted foreign exchange value of the user’s selected currency.</p><p>ng generate pipe CustomCurrencyConvert</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*Pt5_BNCY2ftEQicuopdj3A.png" /><figcaption>Here is a custom pipe that calculates exchanges rates (For simplicity, fx values were hard-coded).</figcaption></figure><p>We can also add a drop down list to dynamically select different currencies. Create data bindings to selected currency and make it able to be selected in a list. In our component, we declare some values:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*qnLmKhijZYI9qQ69i-0gPQ.png" /><figcaption>Note: the implementation of the currency selector is not show but it is fairly simple. You will need to import FormsModule.</figcaption></figure><p><em>kitten.price</em> gets chained by two pipes.</p><pre>&lt;h1&gt;<br>  Kittens<br>&lt;/h1&gt;<br>&lt;div *ngFor=&quot;let kitten of petStoreData.Kittens&quot;&gt;<br>  &lt;ul&gt;Breed: {{ kitten.breed | uppercase }}&lt;/ul&gt;<br>  &lt;ul&gt;Name: {{ kitten.name | capitalize }}&lt;/ul&gt;<br>  &lt;ul&gt;Age: {{ kitten.birthdate | convertToMonths }}&lt;/ul&gt;<br>  &lt;ul&gt;Price: {{ kitten.price <strong>|</strong> <strong>customCurrencyConvert:selectedCurrency | currency:selectedCurrency:&#39;true&#39;</strong> }}&lt;/ul&gt;<br>&lt;/div&gt;</pre><blockquote>Note that we need to call our customCurrencyConvert pipe to change the value <strong>before</strong> we use CurrencyPipe as CurrencyPipe will convert the value to a string.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*cgDn9LGsRiksrUI3dRhv2Q.png" /><figcaption>Here is our outputted values with Korean Won selected.</figcaption></figure><p>Overall, the company’s customers have a more attractive view of the data, plus the currency can be adjustable.</p><p>As well, we created separate pipe files that are separate and easily maintainable in the project.</p><p>In <a href="https://medium.com/@kelvinyan85/learning-angular-pipes-part-ii-89418573eb74">part II</a>, we will discuss Angular’s AsyncPipe, as well as the pure and impure properties.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66b483603792" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>