Friday, June 30, 2017

Introducing Website Speed Test: An Image Analysis Tool

Introducing Website Speed Test: An Image Analysis Tool

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

Because images dominate page weight, methodical image optimization can have a significant effect on conversions and user experience. The performance tools you choose to use can have a powerful impact on how websites are built and maintained. One such popular open source tool is WebPagetest. It is designed to measure and analyze webpage performance, which is why Cloudinary chose to partner with our friends there to launch Website Speed Test.

Website Speed Test is an image analysis tool that provides detailed optimization insights beyond a simple compression check. The tool leverages Cloudinary’s advanced algorithms to demonstrate how changes to image size, format, quality and encoding parameters can result in significant reductions in file size while maintaining perceived quality. In short, Website Speed Test shows the why and how of image optimization.

How Website Speed Test Works

Advanced algorithms take into account many factors when examining images, including the exact content of an image and the need for responsive design. The resulting insights enable you to ensure that images are encoded correctly, optimized for performance, and look their best regardless of bandwidth, viewing browser, device or viewport.

At the top of the page, the report shows the total weight of images, potential compression and ‘Page Image Score’: a grade ranging from A-F. This grade is based on the image format used, fit between image resolution and the displayed size in the graphic design, and compression rate of all the images that were analyzed.

Cloudinary Image Analysis Results

The overview is followed by a detailed analysis of each image, with performance insights and recommendations for improvement.

Left Tab – Current Image

Presents the current version of the image being analyzed along with its image score.

Middle Tab – Optimized Image

Presents an optimized version of the image, using the same format as the original image, with the following adjustments:

  • Correctly-sized images - scales the image down to the actual required dimensions on the web page
  • Intelligent content-aware encoding - analyzes the image to find the best quality compression level and optimal encoding settings, based on the content and viewing browser, producing a perceptually fine image while minimizing the file size.

Learn more about these manipulations

Right Tab - Format Alternatives

This tab shows how optimization works for different image formats and the impact on image weight.

Improved Image Analysis Using WebPagetest

Linked from a new Image Analysis tab, Cloudinary powers WebPagetest with robust image analysis capabilities, enabling you to receive valuable data and guidance on how to manage images and deliver an optimal user experience.

Optimizing Images is No Easy Task

The Website Speed Test tool provides insights on the why and how of optimization. While you may be able to optimize an image or two manually, the process becomes exponentially more complicated when you need to scale up, managing hundreds, thousands, or even millions of images delivered to a website.

For the best user experience, each image should be enhanced and optimized to meet the viewing context. This entails automatically adapting the image to fit the layout of the page and selecting the optimal quality and encoding settings.

Accomplishing this type of optimization is no ordinary feat. Optimizing images for different browsers, devices and bandwidth requires considerable knowledge of the intricacies of image formats, encoding parameters and visual quality metrics. For example, it makes sense that a smaller image file size will result in faster load time, less bandwidth usage and a better user experience. However, reduce the file size too much, and image quality could suffer and impair user satisfaction. This is where Cloudinary’s automatic optimization comes in play.

You can create your free account here.

Continue reading %Introducing Website Speed Test: An Image Analysis Tool%


by Alok Shah via SitePoint

#341: TC39, ECMAScript, and the Future of JavaScript

This week's JavaScript newsRead this e-mail on the Web
JavaScript Weekly
Issue 341 — June 30, 2017
A thorough explanation of how new features make it into JavaScript, before focusing on some practical examples including Array#includes, named captures, and lookbehind assertions in regexes.
Nicolás Bevacqua

Eric Bidelman runs through how to use Headless Chrome, using Karma as a runner and Mocha+Chai for authoring tests.
Google Developers

MONGODB
See the performance implications of using Lambda functions with a database-as-a-service like MongoDB Atlas.
MONGODB   Sponsor

The official spec for ES2017 (essentially the 8th edition of the JS spec) has been published in HTML and PDF if you’re lacking for bedtime reading.
ECMA

A well presented tutorial site complete with rich, live editable examples.
James K Nelson

A full-stack app framework built on React and GraphQL. It’s an evolution of Telescope but is becoming less Meteor-dependent.
Sacha Greif

Includes support for cynamic import() expressions, string enums, improved checking and more.
Microsoft

React Status is our React focused weekly. This week it includes a React Native starter kit and an introduction to Redux-first routing.
React Status

Jobs Supported by Hired.com

Can't find the right job? Want companies to apply to you? Try Hired.com.

In Brief

Babylon, Babel's JS Parser, To Support TypeScript news
Not a lot to see yet, but .ts support has been baked in.
Babel

Microsoft's 'Sonar' Linting Tool Joins the JS Foundation news
Check out Sonar’s homepage to learn more.
Kris Borchers

Use AngularJS to Build a Fast and Secure Chat App 
PubNub gets your data anywhere in less than 0.25 seconds. It’s so easy with PubNub’s AngularJS library.
PubNub  Sponsor

The 'Best' Frontend JavaScript Interview Questions tutorial
Opinions will vary but if you do well at these, you’re in a strong position.
Boris Cherny

Getting Started with Webpack 3 tutorial
João Augusto

Build A Realtime Chart with Vue.js and Pusher tutorial
Yomi Eluwande

Unleash The Power of Angular Reactive Forms video
Oriented around live coding a form from scratch.
Nir Kaufman

Choosing A Frontend Framework in 2017 opinion
This Dot Labs

Why I'm Switching from React to Cycle.js opinion
SitePoint

Using Source Maps to Debug Errors 
Let's talk JavaScript Source Maps. What are they? How to enable source mapping? Why aren't they working?
ROLLBAR  Sponsor

Decaffeinate: Convert Your CoffeeScript to Modern JavaScript tools
A well established project that continues to get frequent updates.
Brian Donovan

An Up to Date List of TC39 Proposals and their Status tools
Nicolás Bevacqua

Search and Install npm Modules Automatically from the Atom Editor tools
Algolia

Infinite Scroll v3: As Users Scroll, Automatically Load More tools
Note it’s both GPL3 and commercial.
Metafizzy

Study: A Progressive, Client/Server AB Testing Library code
Dollar Shave Club

echarts: Powerful Charting and Visualization in the Browser code
Lots of demos here.
Baidu

vanilla-tilt.js: A Dependency-Free, Smooth 3D Element Tilting Library code

RE:DOM: A Tiny (2KB) JS Library for Creating User Interfaces code
Juha Lindstedt

frontexpress: An Express.js-Style JavaScript Router for the Front-End code
Camel Aissani

share-this: Medium-like Text Selection Sharing Without Dependencies code
Massimo Artizzu

ForwardJS Tickets on sale today 
ForwardJS  Sponsor

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. Office 30, Lincoln Way, Louth, LN11 0LS, UK


by via JavaScript Weekly

Square Cash

Square Cash

Stunning One Pager with the most spectacular load animation and background illustrations announcing Square's new Cash App. Shout out to the different positioning of cards and devices on multiple resolutions. A perfect One Pager.

by Rob Hope via One Page Love

Faster Logins With Password AutoFill in iOS 11

Eli Rousso

Eli Rousso

Super long scrolling case-study One Pager by NY-based product designer Eli Rousso who takes us inside his thinking when redesigning a remote. Thank you for such a detailed, visual insight Eli.

by Rob Hope via One Page Love

8 Must Have PHP Quality Assurance Tools

For shipping quality code, we must have testing in mind while coding (if not doing TDD). However, with the wide range of PHP testing tools out there, it's hard to make a choice! Exploring PHP is a fun adventure (premium course on that here!) but it's hard to assemble a toolbelt that's not too heavy to wear to work!

This popular article will highlight the most popular testing tools and has been updated to reflect the state of QA tools in 2017.

Untested code is broken code.

Lab testing environment illustration

PHPUnit

PHPUnit is the go to testing framework for PHP. It was created by Sebastian Bergmann in 2004 and current in version 6 that requires PHP 7.

We have plenty of tutorials coming up about it, but here are some you can already consume.

Cucumber

Cucumber is a framework for creating acceptance tests from specifications. It's known for it descriptive generated texts that can be read as just plain English. The official PHP implementation for Cucumber is Behat.

Behat logo

We have a getting started tutorial about it here on SitePoint. The below example taken from the documentation is a good example on how expressive those expectations are.

Feature: Listing command
  In order to change the structure of the folder I am currently in
  As a UNIX user
  I need to be able see the currently available files and folders there

  Scenario: Listing two files in a directory
    Given I am in a directory "test"
    And I have a file named "foo"
    And I have a file named "bar"
    When I run "ls"
    Then I should get:
      """
      bar
      foo
      """

Atoum

Atoum logo

Atoum is another unit testing framework for PHP. It's a standalone package that you can install via GitHub, Composer or via a PHAR executable file.

Atoum tests are very readable with expressive method names and chaining.

$this->integer($classInstance->myMethod())
        ->isEqualTo(10);

$this->string($classInstance->myMethod())
        ->contains("Something heppened");

You want to learn more about PHP unit testing with Atoum, you can follow this tutorial.

Selenium

Selenium is a tool for automated browser testing (Integration and acceptance testing). It transforms the tests to browser API commands and it asserts the expected results. It supports most of the available browsers out there.

We can use Selenium with PHPUnit using an extension.

composer require --dev phpunit/phpunit
composer require --dev phpunit/phpunit-selenium

Here's a simple example:

Continue reading %8 Must Have PHP Quality Assurance Tools%


by Younes Rafie via SitePoint

Creating a Blogging App Using React, Part 2: User Sign-Up

In the first part of this tutorial series, you saw how to implement the sign-in functionality. In this part, you'll learn how to implement the sign-up functionality and modify the sign-in functionality to check for valid users from MongoDB.

Getting Started

Let's get started by cloning the source code from the first part of the tutorial.

Once the directory has been cloned, navigate to the project directory and install the required dependencies.

Start the Node.js server and you will have the application running at http://localhost:7777/index.html#/.

Setting Up the Back End

For this application, you'll be using MongoDB as the back end. Follow the instructions in the MongoDB official documentation to install MongoDB on Ubuntu. Once you have MongoDB installed, you'll need a connector to connect MongoDB and Node.js. Install the MongoDB Node.js driver using the Node Package Manager (or npm):

Once you have the driver installed, you should be able to require the driver in the application.

Create a file called user.js where you'll keep the user-related stuff. Inside the user.js file, require the MongoDB client-related dependencies.

You'll be using a library called assert to check the returned response. Include assert in the user.js file.

Let's name our database Blog in MongoDB, so our database URL is as shown:

Inside the user.js file, create and export a function called signup

Using the MongoDB client, try to connect to the database. Once connected, you'll log the connected message in the terminal.

Setting Up the Sign-Up Event

Once you have set up the MongoDB back end, let's implement the sign-up event. Inside the main.jsx page, include the on-change event for the name, email and password input text boxes in the signup class.

Bind the above event changes in the class constructor.

Define the state variables inside the signup class constructor.

Define the signup method inside the signup class. Inside the signup method, using the axios library, make a post method call to the signup method in the user.js file. 

Inside the signup function in the user.js file, you'll implement the database insert.

Add the /signup request handler in the app.js file as shown to handle the sign-up click event. Inside the /signup request handler function, make a call to the user.signup method.

Require the user.js file inside the app.js file.

Save the above changes and restart the server. Point your browser to http://localhost:7777/index.html#/signup and you should have the sign-up page. Click on the Sign Up button and you will have the connected message in the terminal.

Save User Details in MongoDB

To save user details in the Blog database, you'll create a collection called user. Inside the user collection, you'll keep all the user details such as name, email address, and password. The MongoClient.connect returns a db parameter using which you can insert an entry in the user collection. 

You'll make use of the insertOne method to insert a single record in the user collection. Modify the code in the signup method in user.js as shown below:

Here is the complete user.js code:

Modify the /signup request handler in the app.js file to pass in the name, email and password to the user.js signup method.

Save the above changes and restart the server. Point your browser to http://localhost:7777/index.html#/signup. Fill the user sign-up details and click the sign-up button. You will have the Saved the user sign up details. message in the server terminal. Log in to the MongoDB shell and check the user collection in the Blog database. To find the user details, enter the following command in the MongoDB shell:

The above command will display the user details in JSON format.

Implementing User Sign-In Check

In the first part of the tutorial, you hard-coded the user sign-in check since the user sign-up hasn't been implemented. Let's modify the hard-coded sign-in check and look into the MongoDB database for valid user sign-ins.

Create a function called validateSignIn in the user.js file. 

Inside the validateSignIn function, using the MongoDB client you'll connect to the Blog database and query the user table for a user with the specified username and password. You'll make use of the findOne method to query the user collection.

Check the returned result for null in case the entry is not found. 

As seen in the above code, if no entry is found, false is returned in the callback. If an entry is found, true is returned in the callback.

Here is the complete validateSignIn method:

In the /signin method in the app.js file, you'll make a call to the validateSignIn method. In the callback function, you'll check for the response. If true, it will indicate a valid sign-in, else an invalid sign-in. Here is how it looks:

Save the above changes and restart the server. Point your browser to http://localhost:7777/index.html#/. Enter a valid username and password and you will have a success message logged in the browser console. On entering an invalid username and password, it would display an error message.

Wrapping It Up

In this part of the tutorial, you saw how to implement the user sign-up process. You saw how to create the sign-up view and pass the data from the React user interface to Node.js and then save it in the MongoDB. You also modified the user sign-in functionality to check for valid user sign-in from the MongoDB database.

In the next part of the tutorial, you'll implement the add post and display post page functionality.

Source code from this tutorial is available on GitHub.

Do let us know your thoughts or any suggestions in the comments below.


by Roy Agasthyan via Envato Tuts+ Code