<?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 Marcus Hellberg on Medium]]></title>
        <description><![CDATA[Stories by Marcus Hellberg on Medium]]></description>
        <link>https://medium.com/@marcushellberg?source=rss-4b18a2d939d1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*s81vHr3VHixznjdd.jpeg</url>
            <title>Stories by Marcus Hellberg on Medium</title>
            <link>https://medium.com/@marcushellberg?source=rss-4b18a2d939d1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 14:42:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marcushellberg/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[Do we still need web frameworks?]]></title>
            <link>https://medium.com/@marcushellberg/do-we-still-need-web-frameworks-f297255503ba?source=rss-4b18a2d939d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/f297255503ba</guid>
            <category><![CDATA[angular2]]></category>
            <category><![CDATA[polymer]]></category>
            <category><![CDATA[framework]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Marcus Hellberg]]></dc:creator>
            <pubDate>Wed, 22 Mar 2017 18:29:05 GMT</pubDate>
            <atom:updated>2017-04-11T15:17:09.948Z</atom:updated>
            <content:encoded><![CDATA[<h3>Do we still need Web frameworks?</h3><h4>The past, present, and future of component-based development on the web</h4><p>In my previous two posts, I’ve compared Polymer and Angular on <a href="https://medium.com/@marcushellberg/simplifying-performance-with-web-components-7d5327314b69">performance</a> and <a href="https://medium.com/@marcushellberg/https-medium-com-marcushellberg-comparing-polymer-and-angular-from-a-developers-perspective-8c3eb9502d78#.uj646cmrx">developer experience</a>. In this final post of the series, I want to take a step back and look at how we ended up in a situation where Google has two models for building components for the web, what that means for developers today, and what the future might bring.</p><h3>A brief look at history</h3><p>Polymer and Angular are perhaps more similar than you realize. For starters, both are Google projects. Both also take a component-based approach to building apps.</p><p>The Polymer project got started in late 2013 as a library and browser <a href="https://www.webcomponents.org/polyfills">polyfill</a> to help developers get started using the Web Components standards that had been introduced two years earlier. Work on Angular 2 began about a year after Polymer, in late 2014. Among the goals for Angular 2 were improved performance and a more scalable, component-based development model. Initially, the Angular team was planning to base the component model on standard components.</p><blockquote>Angular 2 plays nicely with web components built using other libraries (Polymer, X-Tag, and others), allowing you to pass data into them as easily as if they were written in Angular. Angular components use web standards (such as shadow DOM and the HTML5 template tag) in browsers that support them.<br>– <a href="https://web.archive.org/web/20150315222452/https://angular.io/features.html">angular.io, March 2015.</a></blockquote><p>The Angular team later changed their position and built their own component model that is very similar to Web Components, just not tied to the Web Platform. They did this to not be dependent on the DOM. For performance reasons, they wanted to offload some of the browser work to a Web Worker, do pre-rendering on the server and support platforms other than the Web. The downside of this was added complexity — both runtime and development time.</p><p>While both Polymer and Angular have a relatively similar take on what the role of a component is, they differ significantly in how prescriptive they are. Polymer is a small library that builds on top of Web standards. Its component model scales from the use of a single Web Component on a static page to building entire applications. It includes helpers for data binding, routing, and localization, but they are all optional. There are some emerging best practices for how to structure applications, but Polymer doesn’t force any of them on the developer.</p><blockquote>Angular is the Java EE of front-end frameworks</blockquote><p>Angular, on the other hand, is much more opinionated. It’s also more than just a framework; it’s a platform of its own. Angular is the Java EE of front-end frameworks. It provides enterprise developers the tools and patterns they are used to when building complex apps. It has support for routing, dependency injection, localization, pre-rendering and testing. It gives developers a well-defined way of structuring their apps and dealing with data flow, removing a lot of the uncertainty from building an app.</p><h3>Why is Google building both Polymer and Angular?</h3><p>Why is it then that Google has these two separate projects for building component-based Web applications? Wouldn’t it make more sense for Angular to use Web Components as it’s component model? After all, that’s what the Angular 2 team tried to do at first, right?</p><p>I think that Google’s end goal is to make the Web as attractive as it can be for app developers. The Web is after all where they make their money.</p><p>One of the obstacles they identified was that the Web needed a component model to support the building of more complex applications. They needed a quick solution, so Angular 2 was created with its own component model.</p><p>Meanwhile, Google worked with the W3C and other browser vendors to pass standards for adding a component model to the Web platform itself. The standardization process is slow, so they created browser polyfills and the Polymer library to help developers get started using the upcoming features.</p><p>By having both Angular and Polymer, Google can offer a way of building component-based Web apps in the short term while working on a more elegant solution for the long term. It wouldn’t surprise me if future versions of Angular moved over to use (or at least support) Web Components when browser support is universal.</p><h3>Community engagement</h3><p>When it comes to community size and engagement, there’s no question about which one is more popular among developers. Angular has become one of the most popular web frameworks over the last five years, while Polymer and Web Components have remained a very niche technology.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hUaygz8yIwgC5GeA." /><figcaption>Google Trends for Angular (blue) and Polymer (red) over the last five years.</figcaption></figure><p>Polymer is mostly aimed at component developers. The fact is that Web Components alone are a too low-level construct in most cases when building complex apps. Developers want more structure and help, which means that they are looking for frameworks when building larger applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*XOo_inuk3kzkkaQP." /></figure><p>Angular’s popularity also means that there is much more community-generated documentation, courses and other learning material available. You are also more likely to find answers to your Angular questions on Stack Overflow and similar sites. For developers looking for a well-established tool for their next project, especially if they need to get buy-in from their management, Angular looks more appealing at the moment.</p><h3>Paving the way for the next generation of Web frameworks</h3><p>Looking at the developer adoption of Polymer and Angular makes it fairly evident that developers want to use frameworks when building apps. The way I see it, Angular represents the current generation of Web frameworks while Polymer is paving the way for the next generation.</p><p>Building on Web Components, future Web frameworks can be built leaner and faster as they no longer need to build and run their own component models in the browser. The shared component model also means that frameworks can be made more modular. Some projects only need a router; others may additionally need dependency injection, localization or a testing library. Being able to choose only the parts you need will make development easier and the end user experience faster.</p><p>While Web Components are a very powerful concept, I think their biggest impact for most developers is that they are paving the way for a new generation of faster, more light-weight frameworks and tools — a future where every new framework doesn’t need to build its own component set.</p><p><em>Originally published at </em><a href="https://vaadin.com/blog/-/blogs/do-we-still-need-web-frameworks-"><em>vaadin.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f297255503ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Comparing Polymer and Angular from a developer’s perspective]]></title>
            <link>https://medium.com/@marcushellberg/https-medium-com-marcushellberg-comparing-polymer-and-angular-from-a-developers-perspective-8c3eb9502d78?source=rss-4b18a2d939d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c3eb9502d78</guid>
            <category><![CDATA[polymer]]></category>
            <category><![CDATA[angular2]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Marcus Hellberg]]></dc:creator>
            <pubDate>Fri, 17 Mar 2017 18:31:01 GMT</pubDate>
            <atom:updated>2017-04-10T23:13:52.672Z</atom:updated>
            <content:encoded><![CDATA[<p>In my previous post, I showed that <a href="https://medium.com/@marcushellberg/simplifying-performance-with-web-components-7d5327314b69">Polymer has a significant performance advantage over Angular</a>. If you are trying to make your app fast (<a href="https://www.doubleclickbygoogle.com/articles/mobile-speed-matters/">you should be</a>), you are probably wondering if it would make sense to build it with Polymer.</p><p>The potential problem with building an app with Polymer is that Polymer was not initially designed for building applications. It’s a library to help developers work with Web Component APIs (think jQuery for the Web Components APIs).</p><p>Fortunately, the component-based development model offered by Web Components is flexible enough that you can build complex applications using the <a href="https://www.youtube.com/watch?v=ZDjiUmx51y8">browser as your framework</a>. But while it’s possible to create complex apps with Polymer, it’s still missing the structure and guidance a framework gives you.</p><p>In this post, I will compare the development experiences in building the same application in both Angular and Polymer.</p><h3>Tools and languages</h3><p>Both Angular and Polymer come with command-line (CLI) tools that help developers set up and build projects. The CLI tools hide much of the complexity of the build process: taking care of things like transpilation, optimizing and bundling code for production. The Angular CLI additionally (and optionally) performs an Ahead-of-Time (AOT) compilation step to reduce the amount of JavaScript processing that is needed in the browser.</p><h4>Polymer</h4><p>Since Polymer is based on Web standards, components are built with HTML and JavaScript. In Polymer 2 and later, the default language level is ES6, which will get transpiled down to ES5 by the CLI to support older browsers.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3cf5e3f494869a5953ecd8599a621420/href">https://medium.com/media/3cf5e3f494869a5953ecd8599a621420/href</a></iframe><p>Polymer is still fairly limited when it comes to IDE support. The Polymer team is working on improving that through the Polymer IDE plugin that can be used with editors like VS Code and Atom. The Polymer IDE plugin helps developers avoid common mistakes, and offers some autocomplete help. Because Polymer uses plain ES6, there are no type checks.</p><h4>Angular</h4><p>Angular supports development in TypeScript, JavaScript, and Dart. Most documentation and examples that are available online are using TypeScript, which is the de-facto language for building Angular apps. TypeScript is a superset of JavaScript that adds type checking. Type checking gives developers an added layer of checks on the code and can be helpful to ensure APIs are used correctly, especially when working in bigger teams or when using third party libraries.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69912e4c592eb099127664d82f340975/href">https://medium.com/media/69912e4c592eb099127664d82f340975/href</a></iframe><p>The use of TypeScript in Angular also makes it easier for IDEs to offer development time help and checks. Visual Studio Code and WebStorm both have good support for TypeScript, the latter even helping the developer with including imports, making Angular development in an IDE fast despite the amount of boilerplate.</p><h3>Debugging</h3><p>Debugging Polymer applications is straightforward. You can use the browser developer tools to set breakpoints and inspect the running code just like you would with any other front-end technology.</p><blockquote>Most often, debugging the Angular app boiled down to a series of console.log statements</blockquote><p>Angular is much more complex to debug due to the build steps between your code and the code that is running in the browser. The Angular CLI build creates source maps that should allow you to debug the TypeScript code in the browser. In practice, this didn’t work well as the source maps didn’t match the running code and breakpoints didn’t work. There is also a Chrome plugin for debugging Angular apps called Augury that allows you to inspect the hierarchy and status of your components. I did not find the plugin to be very useful in pinpointing issues. Most often, debugging the Angular app boiled down to a series of console.log statements. Error messages in the browser console were cryptic, and stack traces rarely include identifiable code, only Angular internal calls.</p><h3>Application structure and routing</h3><p>Since both Angular and Polymer are component-based, the general application structure is similar. The UI is constructed out of components that get combined into successively more complex components, which are nested until an app emerges. In Angular, you can additionally bundle related components into modules that are used to scope dependencies, and that can be loaded lazily when needed.</p><p>Larger applications are organized into views. The views are typically bound to URLs so that users can link to different parts of the application and use browser navigation buttons to move back and forth. This mapping between view components and URLs is handled by a router.</p><p>Angular ships with a somewhat complex but feature-rich router that supports arbitrarily deeply nested routes. It helps the developer keep the application’s JavaScript size manageable by lazily loading code for modules that aren’t needed until later. It further allows routes to be equipped with Guards, code that is run before or after a view gets activated, to conditionally prevent navigation. The router is configured in a TypeScript file through nested objects.</p><p>Polymer ships an optional <a href="https://www.webcomponents.org/element/PolymerElements/app-route">router</a> that can be used to map between URLs and components. Using the router requires several steps and a lot of repetitive code. You need to add an app-location and anapp-route element to your app to listen for URL changes. Using this information, you can decide what components to show, and optionally (manually) hook up lazy loading of those components.</p><p>By default, Polymer components are only lazily loaded into the DOM, but not removed. This leads to the DOM growing over time in large applications which may result in performance issues, especially on devices with limited memory.</p><blockquote>The limited router is the single biggest factor making it difficult to build large applications in Polymer</blockquote><p>The Polymer router also supports nested routes. In practice, however, using nested routes gets very complicated as the router doesn’t know which view is active so sub-routes will get triggered on all views regardless if they are visible. The router does not either hook up to the build tools, so you need to separately configure views for lazy loading.</p><p>Based on my experience, I feel that the lack of a solid router is the single biggest factor making it difficult to build large applications in Polymer.</p><h3>Working with data</h3><p>Data binding and data flow are important aspects of building apps. One of the functionalities that Polymer provides on top of the Web Components standards is a simple data binding system that supports both one-way and two-way binding of data. One-way data binding is <a href="https://medium.com/dev-channel/custom-elements-that-work-anywhere-898e1dd2bc48#.meth5dlhe">preferred</a> over two-way binding to make it easier to integrate the components with other frameworks and to enable uni-directional data flow patterns like <a href="https://www.youtube.com/watch?v=PahsgJn0sgU">Redux</a>.</p><p>Angular also comes with support for both one-way and two-way data binding. In addition to data binding, it also comes with a Dependency Injection (DI) system that makes it easier to hook up services, especially when testing. Angular builds heavily on RxJS and Observables for handling data, especially for asynchronous HTTP communication. The reactive programming model will take some getting used to if you don’t have experience from before, but enables you to build elegant UI code.</p><p>Editing data in forms is somewhat different in Polymer and Angular. Polymer has a form element that extends the HTML form. All validation is handled by the form elements themselves, which is a bit limiting at times. In Angular, the validation is handled by the framework which makes it easier to combine different components but still have consistent validation.</p><h3>Making it look nice</h3><p>When it comes to customizing the look and feel of your app, Angular is much easier to work with than Polymer. Angular works together with existing CSS libraries like Bootstrap or Semantic UI and you can easily write global CSS to give your app a cohesive look.</p><p>Polymer is harder to customize in terms of look and feel because Web Components are designed to encapsulate their implementations, which means that you need to declare CSS variables and mixins that you import in your components. This means that you cannot use something like Boostrap easily and that it’s hard to get third party components fit your applications look and feel.</p><p>Angular also makes working with dynamic styles easier than polymer, as the template syntax includes a helper for setting style names based on a condition. In Polymer, you need to rely on basic data binding and custom methods which adds a lot of boilerplate.</p><h3>Mobile support: Progressive Web Apps, native apps, or both?</h3><p>Angular and Polymer have different approaches when it comes to mobile support. Angular is more focused on today’s needs, so it includes support for building both Web applications and native applications (although native support requires you to write a separate implementation of the view). They also added support for creating <a href="https://developers.google.com/web/progressive-web-apps/">Progressive Web Applications</a> (PWA) recently.</p><p>For Polymer, PWA is the only mobile strategy. This is in line with Polymer’s goal of building on Web standards to expand what you can do on the Web.</p><h3>Maintainability and stability</h3><p>Angular and Polymer both have a less than stellar track record when it comes to API stability. Polymer had a very rough transition period leading from version 0.5 until 1.0. Likewise, Angular 2 went through an extended period of API changes during development, lasting throughout the release candidates. There have even been some smaller breaking changes within the “stable” 2.x version.</p><p>The good news is that both teams have taken note and are planning for smoother upgrade paths in the future. Polymer 2, currently in <a href="https://www.polymer-project.org/blog/2017-03-08-2-0-rc.html">release candidate</a>, includes support for legacy components so you can migrate applications piece by piece. The Angular team has also promised that breaking changes in Angular 2+ will be easier to migrate, and have hinted several times at a <a href="http://angularjs.blogspot.com/2016/12/ok-let-me-explain-its-going-to-be.html">migration tool</a> to streamline the changes.</p><p>While it’s hard to predict the future, I think that Polymer and the W3C standards it builds on will provide a more stable foundation for apps that need to be maintained for longer periods.</p><h3>Choosing development comfort over performance</h3><p>We know that Polymer allows us to create fast web apps. But it turns out that Polymer by itself is too low-level to easily build big applications. There is clearly still a reason developers are selecting a framework like Angular instead of Polymer. Frameworks help developers structure applications and take care of things like routing, dependency injection, localization and other things you need to deal with when building a large application. Unfortunately, this developer convenience comes at a runtime performance cost to the end user.</p><p>A good first step towards making Web Components suitable for building bigger and more performant apps would be an improved router. It would both help to give structure to apps and make it easier to create apps with tens or hundreds of views.</p><p><a href="https://medium.com/@marcushellberg/do-we-still-need-web-frameworks-f297255503ba">In the last post of this series</a>, I’ll take a look at why Google is working on two competing component-based tools for building web apps and what it might mean for the future of Web frameworks.</p><p><em>Originally published at </em><a href="https://vaadin.com/blog/-/blogs/comparing-polymer-and-angular-from-a-developer-s-perspective"><em>vaadin.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c3eb9502d78" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplifying Performance with Web Components]]></title>
            <link>https://medium.com/@marcushellberg/simplifying-performance-with-web-components-7d5327314b69?source=rss-4b18a2d939d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d5327314b69</guid>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[polymer]]></category>
            <category><![CDATA[angular2]]></category>
            <dc:creator><![CDATA[Marcus Hellberg]]></dc:creator>
            <pubDate>Thu, 02 Mar 2017 23:50:42 GMT</pubDate>
            <atom:updated>2017-03-20T14:49:27.861Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why the solution to slow web apps isn’t a more complex set of tools</h4><p>A while back I was working on an Angular app. What struck me was that Angular is not really only a framework, rather it’s an entire platform of its own built on top the Web platform. The reasoning behind this is to give developers a unified way of building apps across different platforms. But what’s the cost of using this abstraction?</p><p>For you, as a Web developer it means that for most things you know how to do on the Web, there’s a (slightly) different version of accomplishing that in Angular. It also means that you don’t have direct access to new web technologies as they come out, you need to wait for the Angular team to add support for them. ServiceWorker support is a good example.</p><p>Perhaps most importantly though, it means that there’s inevitably a layer of JavaScript running between your application code and the browser that is running the Angular platform. How does this impact performance?</p><p>Angular has put a lot of emphasis on performance in Angular 2 and subsequent releases. The performance builds a highly modular architecture, an Ahead-of-Time (AOT) compiler and pre-rendering. When writing the Angular app, though, I couldn’t help feeling like I could have built the same component-based application using <a href="https://www.webcomponents.org/introduction">Web Components</a> and have it run directly in the browser. Surely, that would be faster?</p><h3>Can we make things easier…and faster?</h3><p>I got support for my idea at Chrome Dev Summit while listening to Alex Russell giving a <a href="https://youtu.be/4bZvq3nodf4">strongly opinionated talk on Web app performance</a>. He went as far as claiming that if you are using a framework, you are “failing by default” when it comes to performance. Frameworks are focusing on catering to developers, often at the cost of end users. The developer needs to consciously work (sometimes around the framework) to deliver a fast experience to their users. I caught up with Alex after his talk, and we had an interesting talk about how these problems get further worsened by real-life devices and networks.</p><p>At this point I was intrigued and wanted to see if I could, in fact, recreate the Angular with nothing but Polymer, and if that app would be faster than the optimized Angular application.</p><p>To keep things more focused, I split my findings into two posts. This first post will cover my initial question, can Web Components be used to build faster web experiences with less tooling? The second part will take a look at the actual developer experience of building an app with these two ways and how we could improve those.</p><h3>Apps and oranges</h3><p>Now some of you may be thinking that isn’t comparing Angular, a framework, with Polymer, a library, a bit like comparing apples and oranges. After all, one is meant for building applications while the other is only concerned with building components.</p><p>Well, as it turns out, the way you build apps out of component is by combining smaller components into more and more complex compositions until you end up with an app. So, to build a component-based app, all you need is a way to make components.</p><p>Both Angular and Polymer ship with their own set of tools to help developers. Most notably, both include a command line (CLI) tool that can be used to bootstrap new projects and build the app for deployment. Polymer also includes some framework-like features like support for routing.</p><h3>My Test Setup</h3><p>To compare the two approaches of building applications, I needed to build the same application with both. The application I developed is a mock portal application listing and showing stats for patients. It consists of three views: 1) a login view, 2) a listing view with master/detail editing, and 3) an analytics view showing chart data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FZnMwzxb8r5z1QyUJbaXyQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2lKRONNZEUSRRBfXLj1SVA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4VVOS231dD3E_lc4N-ZOxw.png" /></figure><p>The Angular application uses <a href="http://www.telerik.com/kendo-angular-ui/components/grid/">Kendo Grid</a> and <a href="http://www.telerik.com/kendo-angular-ui/components/charts/">Charts</a> in addition to the core Angular framework. The Polymer app, in turn, uses <a href="https://vaadin.com/elements/-/element/vaadin-grid">Vaadin Grid</a> and <a href="https://vaadin.com/charts">Charts</a>. While the components are not identical, they are close enough in complexity and functionality to work for this comparison.</p><p>I built the applications following the instructions for production builds. For Angular 2, that meant using Ahead-of-Time (AOT) compilation and production mode in the build (<em>ng build --aot --prod</em>). For Polymer, I used polymer build to create a bundled build (concatenating dependencies into as few files as possible). Both apps used lazy loading of dependencies per view. The Polymer app build process additionally created a Service Worker that pre-loads subsequent views into cache while the user is logging in.</p><p>Both applications were served with Gzip enabled and communicated with the same REST API hosted on localhost. To get more realistic measurements, I used a simulated “Good 3G” connection with a “High-End Device” in Chrome Dev Tools.</p><p>I ran all tests with Chrome. I also ran a comparison test on webpagetest.org against versions deployed on GitHub pages.</p><h3>How fast does this thing go?</h3><p>There was a very clear winner in terms of initial load speed. The Polymer-based app was visually complete and ready to be interacted with in just <em>0.8 seconds</em>. It took the Angular app a whopping <em>4 seconds longer</em> to get done (4.8s). For the initial load, Polymer was 6x faster than Angular.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FuYeNWp6LIdA%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DuYeNWp6LIdA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FuYeNWp6LIdA%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e40355bf37d9c73370ce612d8fc28399/href">https://medium.com/media/e40355bf37d9c73370ce612d8fc28399/href</a></iframe><p>Why is this? Even with AOT compilation, Angular 2 has two distinct disadvantages compared to Polymer. First, since everything is in JavaScript, it needs to get downloaded, parsed, and evaluated before anything can be shown to the user. Polymer, on the other hand, can use the browser’s built-in streaming capabilities to show the app as it’s being downloaded. Second, Web Components are browser-native constructs. No matter how optimized the JS is that Angular outputs, some things are just faster to run directly on the browser itself.</p><blockquote>For the initial load, Polymer was 6x faster than Angular.</blockquote><p>For subsequent page loads, the difference is much less drastic. There are some differences, but I suspect those boil down mostly to the components used on those pages (charts and data grid) than to the technology used. The chart below summarizes the performance measurements for the entire app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*GRA9fz7Cuf6PvS2nZU_Bpg.png" /></figure><p>Interestingly, the app loads faster also when using Safari and the Web Components polyfill:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*BEk1g6B5qmDp8fPUESkGIw.png" /></figure><p>Both apps were roughly the same size in terms of download (Polymer: 630kB, Angular: 689kB) and lines of code (Polymer: 1999 lines, Angular: 1953 lines).</p><p><a href="https://www.webpagetest.org/video/compare.php?tests=170227_FH_144V-r%3A3-c%3A0-l%3APolymer,170227_42_144W-r%3A2-c%3A0-l%3AAngular+2,">The full test can be found here.</a></p><h3>So what about pre-rendering?</h3><p>I could have used pre-rendering in the Angular app to improve the perceived speed. I say perceived because while pre-rendering lets the user see (a good estimation) of the finished page much faster, the added complexity can actually make it slower to get the page interactive. While the scripts are loading, the page looks complete, but nothing happens when a user tries to interact with the page.</p><p>There are other reasons, like SEO, why you might want to do pre-rendering, but as far as performance goes, I wanted to focus on how long it takes to get the app to a usable state.</p><p>It should be noted that Polymer does not support pre-rendering. Instead, the Polymer team is advocating for the use of the <a href="https://developers.google.com/web/fundamentals/performance/prpl-pattern/">PRPL-pattern</a> to achieve speeds comparable to pre-rendering without the added complexity of running the app both on the server and in the browser.</p><h3>Conclusions</h3><p>Web Components are fast. For the initial load, I was able to achieve a 6x speedup compared to the same app implemented in Angular. And I was able to achieve this speedup with a much simpler set of tooling — no AOT compilation, no pre-rendering.</p><p>But another question remains — can you build real, complex apps with only Web Components? It doesn’t do us much good that Web Components are fast if we’re not able to use them to build app. The strength of Frameworks is in the structure they offer to help developers build large, maintainable applications. This is something that Polymer or Web Components in general don’t offer.</p><p>In the <a href="https://medium.com/@marcushellberg/https-medium-com-marcushellberg-comparing-polymer-and-angular-from-a-developers-perspective-8c3eb9502d78">second part of this article</a>, I’ll dive into the developer experience of building these apps and what we might be able to do to make it easier for developers to build blazing fast web experiences.</p><p>The sources for both apps are up on GitHub:</p><p><a href="https://github.com/vaadin/patient-portal-demo-polymer">Polymer app</a></p><p><a href="https://github.com/vaadin/patient-portal-demo-angular">Angular app</a></p><p><em>Originally published at </em><a href="https://vaadin.com/blog/-/blogs/simplifying-performance-with-web-components"><em>vaadin.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d5327314b69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple screenshots with device frame]]></title>
            <link>https://medium.com/@marcushellberg/simple-screen-caps-with-device-frame-a1fbdb4d09ae?source=rss-4b18a2d939d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1fbdb4d09ae</guid>
            <category><![CDATA[chrome]]></category>
            <category><![CDATA[screenshots]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Marcus Hellberg]]></dc:creator>
            <pubDate>Sun, 26 Jun 2016 21:54:33 GMT</pubDate>
            <atom:updated>2016-06-26T21:59:00.322Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/311/1*w6v73y3Aj8ls4iw0mXCE0Q.png" /><figcaption>How do I get a screenshot of my mobile web app running on a device?</figcaption></figure><p>I was trying to figure out a way to get a screen shot of my app running on a device without having to open up Photoshop. Turns out there’s a nifty new feature in Chrome (Canary version 53) allowing you to show the device frame around the device window in dev tools.</p><p>Really simple tip, but hopefully it’ll be helpful to someone else looking to do this.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FxqSZA8e2Wf0%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DxqSZA8e2Wf0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FxqSZA8e2Wf0%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cfd426b6c683d49ee603873dafabe31e/href">https://medium.com/media/cfd426b6c683d49ee603873dafabe31e/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1fbdb4d09ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I sped up the initial render of my Polymer app by 86%]]></title>
            <link>https://medium.com/@marcushellberg/how-i-sped-up-the-initial-render-of-my-polymer-app-by-86-eeff648a3dc0?source=rss-4b18a2d939d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/eeff648a3dc0</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[html5]]></category>
            <category><![CDATA[polymer]]></category>
            <dc:creator><![CDATA[Marcus Hellberg]]></dc:creator>
            <pubDate>Sun, 26 Jun 2016 01:50:41 GMT</pubDate>
            <atom:updated>2016-06-26T01:50:41.438Z</atom:updated>
            <content:encoded><![CDATA[<p>I was trying to optimize the startup time of my Polymer application (<a href="https://wc.demo.vaadin.com/expense-manager/">Expense Manager</a>) and realized that the main reason it took so long to render was that even though the user lands on the login page, the browser was busy setting up the main page that wasn’t even visible yet. In addition, I had all my Polymer elements in one bundle file that needed to get loaded before anything could get shown.</p><p>Here’s what I did to speed up the first meaningful render from about 2,200ms to just over 300ms on localhost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_iRQPdas0r6ap5wIfMLjYQ.png" /><figcaption>Unoptimized: First meaningful paint took about 2,200ms on localhost.</figcaption></figure><h4>Step 1: Split the bundle</h4><p>The first step was to ensure that I’m not loading more than needed for the initial login screen render. The way I decided to do that was to adapt my application to the new project structure that <a href="https://www.polymer-project.org/1.0/docs/tools/polymer-cli">Polymer CLI</a> uses. With this structure, instead of one bundle containing all the elements in the entire app, I got two bundles, one that just contained the components needed to show the login page, and one that contained the rest.</p><p>Splitting up the bundle and deferring the load of the second bundle until navigation sped up the load time considerably. But there was one new issue that it brought with it. Now, after logging in, I had a brief flash of empty screen before the new bundle was actually downloaded and rendered.</p><h4>Step 2: Load the second page in the background</h4><p>While searching for ways to fix the flicker, I stumbled upon an undocumented feature in Polymer, a callback that gets called after a given component has finished rendering.</p><pre>Polymer.RenderStatus.afterNextRender(this.$.login, () =&gt; {<br>  this.importHref(this.resolveUrl(‘overview-page.html’),<br>  null, null, true);<br>});</pre><p>With this callback, I was able to begin downloading and rendering the overview page as soon as the login page was rendered. Because users are slow compared to computers, this meant that by the time the user actually logs in, everything is already set up for them and the transition is instant.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GMa4vk_0wxLC_BVVt8HCIg.png" /><figcaption>Optimized: First meaningful paint takes just over 300ms on localhost. Most of the heavy lifting happens while the user is performing the login.</figcaption></figure><h4>Step 3: Fetch data only once render is complete</h4><p>One final optimization I did using the same trick was to delay the <a href="https://pouchdb.com/">Pouch DB</a> setup until the second page was fully rendered. This way, the user gets quick visual results and the overall experience feels snappier .</p><pre>Polymer.RenderStatus.afterNextRender(this, () =&gt; {<br>  this._setupDB();<br>});</pre><h4>Conclusion</h4><p>Polymer.RenderStatus.afterNextRender gives you a simple way to defer things that need to get done soon, but that don’t need to get done in the next render.</p><p>You can find the demo online at: <a href="https://wc.demo.vaadin.com/expense-manager/">https://wc.demo.vaadin.com/expense-manager/</a> and source code at <a href="https://github.com/vaadin/expense-manager-demo">https://github.com/vaadin/expense-manager-demo</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eeff648a3dc0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Progressive Web Apps are about more than quick load times and offline support]]></title>
            <link>https://medium.com/@marcushellberg/progressive-web-apps-are-about-more-than-good-ux-they-are-about-inclusiveness-ba38a14bef6b?source=rss-4b18a2d939d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba38a14bef6b</guid>
            <category><![CDATA[pwa]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Marcus Hellberg]]></dc:creator>
            <pubDate>Thu, 23 Jun 2016 16:17:15 GMT</pubDate>
            <atom:updated>2016-06-23T16:21:42.687Z</atom:updated>
            <content:encoded><![CDATA[<p>Progressive Web Application (PWA) is a term covering best practices for building applications that leverage the strengths of the web while addressing some of the key areas that have previously pushed developers to write native applications — offline support, home screen access and push notifications for keeping engaged.</p><p>Initially it was the promise of being able to improve an app I was working on that drew me to experimenting with building PWAs. And indeed, using the things I learned, I was able to provide a radically faster experience for users while allowing them to interact the app even if they happen to lose connectivity in a tunnel. PWAs were certainly delivering on their promise of improving the user experience for users, especially those with bad connections.</p><p>Earlier this week I attended the PWA Developer Summit in Amsterdam and saw a presentation by <em>Tal Oppenheimer</em> about building web experiences for the next billion and <em>Andrew Mori</em> about building web apps for Nigerian users. Listening to these talks, it dawned upon me that while I had been focusing on the UX improvements that Progressive Web Apps bring, PWAs really solve a much more important issue on the Web platform.</p><blockquote>Delivering near instant load times and snappy in-app experiences are not the reason we should care about building PWAs, they are just fortunate side effects.</blockquote><p>People who are coming online for the first time today are mostly located in developing countries and their experience connecting to the internet is radically different from what I’m used to. The majority of new users are relying on mobile networks and devices that are fairly modest. 2G networks are still the norm in many places for years to come. Data is VERY expensive. So expensive that installing an application can cost the equivalent of 5–10% of the local monthly minimum wage. Building an app that also works well in these conditions require us to rethink a lot of how we build apps.</p><h4>Small thought experiment</h4><blockquote>Say you are an engineer from the USA, making $80,000/year. You are on a trip abroad. Using the internet on your phone costs $3.50/MB while roaming and in addition download speeds are capped at 100kb/s.</blockquote><blockquote>Would you use your phone differently under these conditions than at home? Would it seem reasonable to spend more than 20 minutes and $420 to download the latest version of Facebook’s native app (120MB) for instance?</blockquote><p>So, while adapting Progressive Web App technologies in your app may only translate to a slightly snappier experience or less hassle for your current users, it may actually make the difference between a user in India or Africa being able to use your app or not. Mobile first and offline first take on an entirely different meaning in this setting.</p><p>If you have 20 minutes, I can highly recommend watching Tal’s talk below:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVmg1ECC2r2Q%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVmg1ECC2r2Q&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FVmg1ECC2r2Q%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e9b16cbbd2f2c4cd5463becfff65322/href">https://medium.com/media/9e9b16cbbd2f2c4cd5463becfff65322/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba38a14bef6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>