Friday, November 24, 2017

Progressive Web Apps: A Crash Course

Progressive Web Apps (PWAs) try to overlap the worlds of the mobile web apps and native mobile apps by offering the best features of each to mobile users.

They offer an app-like user experience (splash screens and home screen icons), they're served from HTTPS-secured servers, they can load quickly (thanks to page load performance best practices) even in low quality or slow network conditions, and they have offline support, instant loading and push notifications. The concept of PWAs was first introduced by Google, and is still supported by many Chrome features and great tools, such as Lighthouse, an open-source tool for accessibility, performance and progressiveness auditing which we'll look into a bit later.

Throughout this crash course, we'll build a PWA from scratch with ES6 and React and optimize it step by step with Lighthouse until we achieve the best results in terms of UX and performance.

The term progressive simply means that PWAs are designed in a such a way that they can be progressively enhanced in modern browsers where many new features and technologies are already supported but should also work fine in old browsers with no cutting-edge features.

Native vs Mobile = Progressive

A native app is distributable and downloadable from the mobile OS's respective app store. Mobile web apps, on the other hand, are accessible from within a web browser by simply entering their address or URL. From the user's point of view, launching a browser and navigating to an address is much more convenient than going to the app store and downloading, installing, then launching the app. From the developer/owner's point of view, paying a one-time fee for getting an app store account and then uploading their apps to become accessible to users worldwide is better than having to deal with the complexities of web hosting.

A native app can be used offline. In the case of remote data that needs to be retrieved from some API server, the app can be easily conceived to support some sort of SQLite caching of the latest accessed data.

A mobile web app is indexable by search engines like Google, and through search engine optimization you can reach more users. This is also true for native apps, as the app stores have their own search engines where developers can apply different techniques --- commonly known as App Store Optimization --- to reach more users.

A native app loads instantly, at least with a splash screen, until all resources are ready for the app to execute.

These are the most important perceived differences. Each approach to app distribution has advantages for the end user (regarding user experience, availability etc.) and app owner (regarding costs, reach of customers etc.). Taking that into consideration, Google introduced PWAs to bring the best features of each side into one concept. These aspects are summarized in this list introduced by Alex Russell, a Google Chrome engineer. (Source: Infrequently Noted.)

  • Responsive: to fit any form factor.
  • Connectivity independent: progressively-enhanced with service workers to let them work offline.
  • App-like-interactions: adopt a Shell + Content application model to create appy navigations & interactions.
  • Fresh: transparently always up-to-date thanks to the service worker update process.
  • Safe: served via TLS (a service worker requirement) to prevent snooping.
  • Discoverable: are identifiable as “applications” thanks to W3C Manifests and service worker registration scope allowing search engines to find them.
  • Re-engageable: can access the re-engagement UIs of the OS; e.g. push notifications.
  • Installable: to the home screen through browser-provided prompts, allowing users to “keep” apps they find most useful without the hassle of an app store.
  • Linkable: meaning they’re zero-friction, zero-install, and easy to share. The social power of URLs matters.

Lighthouse

Lighthouse is a tool for auditing web apps created by Google. It's integrated with the Chrome Dev Tools and can be triggered from the Audits panel.

You can also use Lighthouse as a NodeJS CLI tool:

npm install -g lighthouse  

You can then run it with:

lighthouse https://sitepoint.com/

Lighthouse can also be installed as a Chrome extension, but Google recommends using the version integrated with DevTools and only use the extension if you somehow can't use the DevTools.

Please note that you need to have Chrome installed on your system to be able to use Lighthouse, even if you're using the CLI-based version.

Building your First PWA from Scratch

In this section, we'll be creating a progressive web app from scratch. First, we'll create a simple web application using React and Reddit's API. Next, we'll be adding PWA features by following the instructions provided by the Lighthouse report.

Please note that the public no-authentication Reddit API has CORS headers enabled so you can consume it from your client-side app without an intermediary server.

Before we start, this course will assume you have a development environment setup with NodeJS and NPM installed. If you don't, start with the awesome Homestead Improved, which is running the latest versions of each and is ready for development and testing out of the box.

We start by installing Create React App, a project boilerplate created by the React team that saves you from the hassle of WebPack configuration.

npm install -g create-react-app
create-react-app react-pwa
cd react-pwa/

The application shell architecture

The application shell is an essential concept of progressive web apps. It's simply the minimal HTML, CSS and JavaScript code responsible for rendering the user interface.

App Shell

This app shell has many benefits for performance. You can cache the application shell so when users visit your app next time, it will be loaded instantly because the browser doesn't need to fetch assets from a remote server.

For building a simple UI we'll use Material UI, an implementation of Google Material design in React.

Let's install the package from NPM:

npm install material-ui --save

Next open src/App.js then add:

import React, { Component } from 'react';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import AppBar from 'material-ui/AppBar';
import {Card, CardActions, CardHeader,CardTitle,CardText} from 'material-ui/Card';
import FlatButton from 'material-ui/FlatButton';
import IconButton from 'material-ui/IconButton';
import NavigationClose from 'material-ui/svg-icons/navigation/close';

import logo from './logo.svg';
import './App.css';

class App extends Component {

  constructor(props) {
    super(props);

    this.state = {
      posts: []
    };
  }

  render() {
    return (

      <MuiThemeProvider>
        <div>
          <AppBar
            title={<span >React PWA</span>}

            iconElementLeft={<IconButton><NavigationClose /></IconButton>}
            iconElementRight={<FlatButton onClick={() => this.fetchNext('reactjs', this.state.lastPostName)} label="next" />
            }
          />

          {this.state.posts.map(function (el, index) {
            return <Card key={index}>
              <CardHeader
                title={el.data.title}

                subtitle={el.data.author}
                actAsExpander={el.data.is_self === true}
                showExpandableButton={false}
              />

              <CardText expandable={el.data.is_self === true}>
                {el.data.selftext}
              </CardText>
              <CardActions>
                <FlatButton label="View" onClick={() => {
                  window.open(el.data.url);
                }} />

              </CardActions>
            </Card>
          })}


          <FlatButton onClick={() => this.fetchNext('reactjs', this.state.lastPostName)} label="next" />
        </div>
      </MuiThemeProvider>

    );
  }
}

export default App;

Next we need to fetch the Reddit posts using two methods fetchFirst() and fetchNext():

  fetchFirst(url) {
    var that = this;
    if (url) {
      fetch('http://ift.tt/1sZr1Ax' + url + '.json').then(function (response) {
        return response.json();
      }).then(function (result) {

        that.setState({ posts: result.data.children, lastPostName: result.data.children[result.data.children.length - 1].data.name });

        console.log(that.state.posts);
      });
    }
  }  
  fetchNext(url, lastPostName) {
    var that = this;
    if (url) {
      fetch('http://ift.tt/1sZr1Ax' + url + '.json' + '?count=' + 25 + '&after=' + lastPostName).then(function (response) {
        return response.json();
      }).then(function (result) {

        that.setState({ posts: result.data.children, lastPostName: result.data.children[result.data.children.length - 1].data.name });
        console.log(that.state.posts);
      });
    }
  }
  componentWillMount() {

     this.fetchFirst("reactjs");
}

You can find the source code in this GitHub Repository.

Before you can run audits against your app you'll need to make a build and serve your app locally using a local server:

npm run build

This command invokes the build script in package.json and produces a build in the react-pwa/build folder.

Now you can use any local server to serve your app. On Homestead Improved you can simply point the nginx virtual host to the build folder and open homestead.app in the browser, or you can use the serve package via NodeJS:

npm install -g serve
cd build
serve

With serve, your app will be served locally from http://localhost:5000/.

Reddit PWA

You can audit your app without any problems, but in case you want to test it in a mobile device you can also use services like surge.sh to deploy it with one command!

npm install --global surge

Next, run surge from within any directory to publish that directory onto the web.

You can find the hosted version of this app from this link.

Now let's open Chrome DevTools, go to Audits panel and click on Perform an audit.

Lighthouse report

From the report we can see we already have a score of 45/100 for Progressive Web App and 68/100 for Performance.

Under Progressive Web App we have 6 failed audits and 5 passed audits. That's because the generated project already has some PWA features added by default, such as a web manifest, a viewport meta and a <no-script> tag.

Under Performance we have diagnostics and different calculated metrics, such as First meaningful paint, First Interactive, Consistently Interactive, Perceptual Speed Index and Estimated Input Latency. We'll look into these later on.

Lighthouse suggests improving page load performance by reducing the length of Critical Render Chains either by reducing the download size or deferring the download of unnecessary resources.

Please note that the Performance score and metrics values can change between different auditing sessions on the same machine, because they're affected by many varying conditions such as your current network state and also your current machine state.

Continue reading %Progressive Web Apps: A Crash Course%


by Ahmed Bouchefra via SitePoint

A Concise Comparison of JavaScript Web Frameworks

This week's JavaScript newsRead this e-mail on the Web
JavaScript Weekly
Issue 362 — November 24, 2017
An 11 part series comparing Aurelia, Ember, Dojo, Vue, React and Angular reaches its conclusion by looking at the pros and cons of each.
Kit Kelly

Writing the same app in Angular & Vue and comparing both the similarities and differences.
John Papa

Instantly know whats broken and why. Get real-time monitoring, alerting, analytics for JavaScript errors. Learn more.
Rollbar   Sponsor

Dynamic import() is a new function-like form of import, but why could it be useful? Currently in beta versions of Chrome and Safari only.
Google Developers

A new library that provides a declarative way to perform common tasks against cloud-based services (AWS for now, but it’s open to be extended to support other services).
Amazon Web Services

Complete with custom cell editors, keyboard control support, and resizable columns. Demo.
Denis Raslov

The what, why, and how behind using a library for efficient ‘scrollytelling’ that uses IntersectionObserver in favor of scroll events.
Russell Goldenberg

An introduction to CodeStubAssembler (CSA), a component in V8 that “has been a very useful tool in achieving some big performance wins over the last several V8 releases”.
Mathias Bynens

In Brief

Submit Your Article/Tutorial to our 66K Follower Medium Publication news
DailyJS is our Medium publication, currently with 66K followers. We’re happy to receive submissions.
Chris Brandrick

77% of 433,000 Sites Use Vulnerable JavaScript Libraries news
The results of an open source security report.
Tim Kadlec

A Free 'Intro to Node.js' Course from Microsoft course
Benjamin Lin and Azat Mardan

Developing Real-Time Apps with Meteor tutorial
How to use Meteor to build a real-time web app and add authentication to it.
Prosper Otemuyiwa

Implementing Functors and Monads in JavaScript tutorial
Rubens Pinheiro Gonçalves Cavalcante

Using Angular Components with Third-Party Libraries tutorial
Netanel Basal

How to Handle Errors with Try, Throw, Catch, and Finally tutorial
Brandon Morelli

Passing Data Between Routes in a Vue.js App tutorial
Nic Raboy

PureScript: Tomorrow's JavaScript Today? video
A tour of a strongly-typed functional language that compiles to JS.
Kris Jenkins

Why We Have Banned Default Exports in JavaScript and You Should Do The Same opinion
Krzysztof Kaczor

A Much Faster Way to Debug Code Than with Breakpoints or Console.log 
Quokka catches errors & displays the results of expressions as you type. Community edition is free as in beer.
Wallaby.js  Sponsor

synp: Convert yarn.lock to package-lock.json and Vice Versa tools
Handy if your team ends up flip-flopping between Yarn and npm, say.
Aram Drevekenin

G2: A 'Grammar' for Building Data-Driven Visualizations code
AntV Team

Introducing the Amazon DynamoDB DataMapper for JavaScript code
Amazon Web Services

Reframe.js: Reframe Unresponsive Elements Responsively code
Dollar Shave Club

imaskjs: A Vanilla JavaScript Input Mask code
Covers formats like dates and phone numbers, but also regexes.

UPNG.js: Now Even Better PNG Minification code
It’s 6x faster than before and creates better palettes for dithering.
Photopea

Z: Pattern Matching for JavaScript code
Though not quite the same as the official ES pattern matching syntax proposal.

Curated by Peter Cooper and published by Cooperpress.

Like this? You may also enjoy: FrontEnd Focus : Node Weekly : React Status

Stop getting JavaScript Weekly : Change email address : Read this issue on the Web

© Cooperpress Ltd. Fairfield Enterprise Centre, Lincoln Way, Louth, LN11 0LS, UK


by via JavaScript Weekly

24 Productivity Tools to Help You with Almost Everything

This article was sponsored by Mekanism. Thank you for supporting the partners who make SitePoint possible.

With such high competition in the market, how do you make sure you're project, product or idea cuts through? And in a timely manner? The difference is made by the talent, learning new technologies and last, but not least, by the tools used. There are a heap of productivity tools out there that are helping web designers and developers to design logos, build phone apps without the need for coding skills or even build a database quickly and efficiently.

In this showcase, we will take you through 25 of our favourite tools to help you overcome almost anything. We hope that you will find these helpful. Let us know your thoughts or if you have some other recommendations to add to the list.

1. Tailor Brands - Automated Logo Maker and Brand Builder 

Tailor Brands

Tailor Brands has quickly grown to be one of the best tools on the market to help you design logos and make branding. After offering up a great logo maker, the company now offers a full branding suite that makes marketing and creating unique company visuals a breeze.

The company’s logo maker uses AI and pairs it with an expansive template library to create unique and effective designs in a matter of minutes. You can then fine-tune aspects of your logo until it's perfect.

Now that you have your logo, you can move on to making your mark with a powerful online brand presence. Tailor Brands is easy-to-use and gives you a fully automated weekly social planner that sets a schedule and auto-generates posts and ads to upload on a regular basis, you can also add more posts in manually if you'd like.

If you want to launch a holiday campaign, you can take advantage of Tailor Brands’ seasonal logos, which lets you give your branding a quick boost. For your business needs, you can create business cards and decks to go along with letterheads, and even presentation templates. You can also download your logo in EPS format to print it on shirts, bag, and other gear.

With a basic monthly subscription of $2.99 or a full package for $10.99, Tailor Brands is a quick and easy way to give your brand a professional touch.

Pricing: Monthly subscription from $2.99.

2. iGenApps - Build Your Phone App Without Any Coding Skills

iGenApps

iGenApps is a powerful and affordable app builder that allows people without programming skills to build and publish a fully customized app. According to the company, it has been downloaded 2 million times and has more than 1.5 million registered users building their apps with it already. And in April 2017, it was named the Best Productivity App.

You start the app creation with the wizard building process that will guide you step by step to build Apps for mobile phones and tablets. Build and publish your Apps in minutes all through your mobile device.

iGenApps has a free trial you can start playing with that will show you how it all works and what it can do.

Pricing: Check their website for detailed pricing.

3. Kohezion - Online Database Software

Kohezion

Kohezion is an advanced online database software that allows you to quickly create your own customized web-based database without coding or any programming. The database can be used for:

  • Clients – Easily manage your clients, leads, organization and more. You can create reminders so you will never lose an opportunity. Keep a record of all communications and attach files to client's records
  • Manage Contracts - Collaborate and share ideas about contracts. Never miss an expiration date with reminders. Easily track all required information. Attach files, Apply calculations or Email contracts directly from Kohezion
  • Manage tasks
  • Schedules

It is also highly customizable. You can create custom quotes and invoices for your clients, custom reports with your own look and feel, integrate with Dropbox™, Google Drive™ or Box™, create complex calculation fields, or even embeddable online forms.

There are 3 types of plans, standard, non-profit organizations and enterprise solutions, with pricing starting at $50/user/year. They also have a Free Forever plan, which will cover your basic needs.

Pricing: Starts from $50/User/YEAR for full access or they also have a Free Forever plan.

4. Visme

Visme

When it comes to Visual Communication, Visme is a game changer.  Imagine taking key features of Powerpoint and Photoshop and then marrying them together into an easy-to-use tool. It allows people without design experience to tap into hundreds of professional templates and an extensive library of assets to create engaging and memorable presentations, infographics, charts and report, ebooks, websites and social graphics. You can even make your content interactive with the ability to insert videos, audio or embed external content such as forms, polls, and maps.  

You can publish your content online, embed to your website, make it private and password protected or download it as an Image, PDF or even HTML5, so you can present offline.

Pricing:Paid plans start at $10/month which unlock premium features including the ability to customize your own brand, upload your own fonts, and tap into all premium templates and images. But they also have a free plan.

5. Ultra Theme

Ultra Theme

Ultra Theme is a powerful and flexible WordPress theme created by the well reputed Themify. It is easy to use and makes creating sites quickly and beautifully (and responsive, of course), a breeze. It allows you to take full control of your theme design from header to footer.

Pricing: The standard license is $49.

6. Codester.com

Codester

Codester is a fast growing platform for web designers and developers to buy and sell lots of great premium PHP scripts, app templates, themes and plugins to create amazing websites & apps. They even have a “flash sales” where products are available for a limited period but with a 50% discount.

Pricing: It's a marketplace, so will vary on products.

7. GrapeCity - JavaScript Solutions

GrapeCity

GrapeCity JavaScript solutions provides all you'll need for a full web app. With this you'll get dependency-free, fast, flexible, true JavaScript components that enable you to build basic websites, full enterprise apps, and Excel-like spreadsheet web apps. And if you need it, expert support is available by forum, direct ticket or phone.

There are 2 products: SpreadJS and Wijmo and both have offer free trials.

Pricing: SpreadJS is $999/developer and Wijmo is $895/developer.

8. ThemeFuse.com

ThemeFuse

ThemeFuse is one of the most impressive WordPress theme developers in the market. They cover most domains such as automotive, blogging, e-commerce, events and portfolios. Their themes are professional-looking and includes everything you need to get started and the installation and setup only takes a couple of minutes, so you can get started with your next big idea.

Pricing: They offer a free plan, but the premium ones start from $45, paid once.
You can also use this code BLKFRY2017 and get a 70% discount.

9. Blaskan

Blaskan

Blaskan is a responsive and professional WordPress theme that's built for many kinds of screens. It was built by Colorlib, a new WordPress developer that is quickly becoming one of the best in the market. The theme is free to download and use, so give it a try.

Pricing: Free

10. VectorStock.com

VectorStock

VectorStock is the world’s premier vector-only image marketplace with more than 10,000 vectors added daily. It’s one of the favorite places for web designers because there is a heap to be found here and also because the pricing is budget friendly.

Pricing: Free plan with access to 41,000 free vectors and millions of royalty free images.

11. wpKube

wpKube

wpKube specializes in WordPress themes, hosting, plugins and everything related to this platform. They've even made a complete guide about how you can start a WP website from scratch, which tools, themes and hosting to choose from, so you can have an awesome website.

They're also investing lots of money in developing new themes. All of their templates are fully responsive, easy to install, setup and customize. At this point, there are 5 themes and the pricing is between $49-$59/theme.

Pricing: Varies depending on service you are after

12. Host-Tracker.com

Host Tracker

Host-Tracker is one of the best website monitoring systems on the market. It provides instant notifications about failures, domain and certificate expiration monitoring, content check and many other cool things. They recently launched a cool new feature which automatically pauses your AdWords campaign if any problems with the site are detected and then reactivates onces resolved.

Pricing: $5/month with a 50% discount for new customers

Continue reading %24 Productivity Tools to Help You with Almost Everything%


by Alex via SitePoint

Oh Your Lash

Luxury Faux Mink Lashes


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

Instagram Marketing Hacks for 2017 - #Infographic

Instagram is the new hot social media channel that most businesses are running to to market their products and services. In this infographic, there are many ways in which you can market your brand on Instagram at zero or minimum marketing spend.

[ This is a content summary only. Visit our website http://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Web Desk via Digital Information World

10 Best iOS Photo App Templates

Performant Animations Using KUTE.js: Part 5, Easing Functions and Attributes

So far in this series, you have learned how to animate the CSS properties of different elements, how to create different SVG-related animations, and how to animate the text content of different elements on a webpage. There is one more way in which you can animate the elements on a webpage using KUTE.js, and that is by changing the values of different attributes. This requires you to include the attributes plugin in your project.

In this tutorial, you will learn how to use the attributes plugin to animate the value of different kinds of attributes in KUTE.js. We will also discuss different easing functions that you can use to control the pace of different animations.

Easing Functions

Objects in real life very rarely move linearly. They are either accelerating or decelerating. Even the acceleration and deceleration occur at different magnitudes. Up to this point, all our animations have progressed linearly. This doesn't feel natural at all. In this section, you will learn about all the easing functions that KUTE.js provides for controlling the pace of different animations.

The core easing functions in the library are included in the core engine out of the box. Let's say you want to apply the QuadraticInOut easing to an animation. This can be achieved in two ways:

Each of the easing functions has a unique curve that determines how the elements will accelerate during the animation. A sinusoidal curve implies linear acceleration. Keep in mind that this is different from the linear easing function. The linear function implies a linear speed of animation, while a sinusoidal curve implies a linear speed of acceleration for the animation. In other words, the speed of the animation will increase or decrease linearly. Similarly, quadratic implies acceleration with a power of two, cubic implies a power of three, quartic implies a power of four, and quintic implies a power of five. There are also circular and exponential easing functions.

You can append In, Out, or InOut to any of the easing functions. The value In implies that the animation will start very slowly and keep accelerating until the end. The value Out implies that the animation will start at the maximum speed and then decelerate slowly until it comes to a halt at the end. The value InOut means that the animation will speed up at the beginning and slow down at the end.

You can also use bounce and elastic easing functions in your animations and append In, Out, or InOut to any of them. In the following demo, I have applied all these easing functions on different circles so that you can see how they affect the pace of the animation.

It is possible that none of the core easing functions provide the animation pace that you are looking for. In such cases, you can include the Cubic Bezier functions in your project from the experiments branch and start using those easing functions. 

Similarly, KUTE.js also provides some physics-based easing functions imported from the Dynamics.js library. You can read more about all these easing functions and how to properly use them on the easing function page of the library.

Animating Attributes

Attributes in SVG can accept numbers as well as strings as their value. The strings can be color values or numbers suffixed with a unit like px, em, or %. The names of the attributes themselves can also consist of two words joined by a hyphen. Keeping these differences in mind, KUTE.js provides us different methods that can be used to specify the values of different attributes.

As you can see, suffixed values need to be enclosed within quotes. Similarly, attributes which contain a hyphen in their name need to be enclosed inside quotes or specified in camelCase form.

Unitless Attributes

A lot of attributes accept unitless values. For example, the stroke-width of a path could be unitless. Similarly, you don't have to specify a unit for the r, cx, and cy attributes of a circle element. You can animate all these attributes from one value to another using the attributes plugin. 

Now that you know how to use different easing functions, you will be able to animate different attributes at different paces. Here is an example:

The first tween animates the radius of both circles at once using the allTo() method we discussed in the first tutorial. If set to true, the yoyo attribute plays the animation in the reverse direction. 

The cx attribute of both the circles is animated individually. However, they are both triggered by the same button click. Finally, the cy attribute of both the circles is animated at once with an offset of 1000 milliseconds.

Color Attributes

Starting from version 1.5.7, the attribute plugin in KUTE.js also allows you to animate the fill, stroke, and stopColor attributes. You can use valid color names or hex values for the colors. You can also provide the color values in RGB or HSL format. 

One important thing that you have to keep in mind is that the animations will only seem to work if you are not setting the value of these properties in CSS. In the following demo, the fill color wouldn't have animated at all if I had added the following CSS in our demo.

The demo I created is very basic, but you can make it more interesting by applying transforms and using more colors.

Suffixed Attributes

A lot of SVG attributes like r and stroke-width can work with and without suffixes. For example, you can set the value of r to be a number like 10 or in terms of em units like 10em. There are some attributes like offset attribute for color stops that always require you to add a suffix. While specifying a value for suffixed attributes in KUTE.js, always make sure that you enclose the value within quotes.

In the following example, I have animated the offset value of the first stop in a gradient and the color of the second stop. Since offset requires a suffix, I have enclosed the value inside quotes.

There are three different gradients in the demo, and each of these gradients has two color stops with the class names stop1 and stop2. I have also applied a scale transform using the svgTransform attribute, which we discussed in the third tutorial of the series.

Final Thoughts

In this tutorial, you learned about different easing functions available in KUTE.js and how you can use them to control the pace of your own animations. You also learned how to animate different kinds of attributes.

I have tried to cover all the important aspects of KUTE.js in this series. This should be enough to help you use KUTE.js confidently in your own projects. You can also read the documentation in order to learn more about the library. 

I would also recommend that you go through the source code and see how the library actually works. If you have any questions or tips related to this tutorial, feel free to share them in the comments.


by Monty Shokeen via Envato Tuts+ Code