Javascript News

Syndicate content
Pipes Output
Updated: 48 weeks 6 days ago

Validating your data with Respect Validation

Fr, 2015-07-17 16:00

Validation is an important aspect of every application’s interaction with data. Instead of reinventing the wheel every time, the community collaborated on some useful packages like Symfony, Laravel, Zend, etc. In this article, we’re going to introduce a new package called Respect Validation, which provides some nice new features. Let’s get started.

Popular Validation Packages

When using a framework, there is a great chance that you have a validation component shipped with it. The Symfony Validator Component provides a set of standard validation rules that you’ll need for your application.

class UserSubscriptionForm { protected $email; public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('email', new \Assert\Email([ 'message' => 'Invalid email.' ])); } }

I’m sure your subscription form contains more than just an email, but let’s keep it simple. Inside your controller you’ll have to trigger the validation like so:

public function store(Request $request){ $userSubscriptionForm = UserSubscriptionForm::fromInput($request->all()); $validator = $this->get('validator'); $errors = $validator->validate($userSubscriptionForm); if (count($errors) > 0) { // redirect with errors } // return success }

Continue reading %Validating your data with Respect Validation%

6 Tips for Writing Good Content Faster

Fr, 2015-07-17 16:00

I write a sh!t load of content. I’m on the hook to write or edit 10 posts per week (on top of running a content marketing agency). When I first got started, I was in over my head. I was struggling to manage the volume, client requests, deadlines and editors. The result was a stream […]

Continue reading %6 Tips for Writing Good Content Faster%

UX Design for Passwords and Registration Forms

Fr, 2015-07-17 15:14

Forms are a crucial part of the web design in 2015, especially since the rise of mobile has forced us to concentrate that much harder on smoothing our UXs.

Forms are often central to driving conversions in ecommerce sites and are often the difference between a successful user registration and the user leaving a site never to return.

From a user perspective, forms should clearly communicate to the user what is required from them. They should be effortless to click into and type in, regardless of the device that they're accessed on. And they should display with correctly aligned labels that indicate what the user needs to enter into a given field.

While it was once considered standard practice to ask for as much information as possible – on the off chance you may need this information later – that's not the case today. Forms should be not a character longer than is absolutely necessary.

[caption id="attachment_110580" align="aligncenter" width="765"] Image credit: Will Scully-Power[/caption]

Research has shown that shorter forms can increase conversions by as much as 160%, so a poorly designed form, or one that demands too much data can directly impact revenue.

Users Don't Like Registering

Users are growing increasingly resistant to traditional registration processes, and studies have shown that up to 86% of people will change their behavior if they are forced to create a user account.

A study conducted by Blue Research further found that, when questioning users:

  • 54% stated they might leave the site
  • 26% said they would choose another site that didn't require registration
  • 6% said they would leave and avoided the site in the future
  • 14% stated that they would complete registration

Further to this, 88% said that they have given incorrect information on a form when registering on a site and 90% said that rather than retrieve account information from a site they had previously registered on, they simply left.

The consistent message from users is clear: they prefer to not register and will avoid it if at all possible. What's more, this resistance is also growing. Given the choice over account creation, many users would more happily use social logins for all of their accounts.

So, we know forms need to be short, simple and while it's sometimes handy to have a lot of information about customers from the business perspective, it's not valuable if it seriously impacts revenue.

Satisficing

In her article Satisficing: What Does it Mean for Web Forms, Jessica Enders explains that,

The term “satisficing” refers to the human tendency to expend only the minimum amount of energy required to successfully complete a task. This is a subconscious phenomenon: (most of the time) we don’t sit down to do something and think “I’m going to spend the bare minimum on this”.

So when crafting forms, it's necessary to design with satisficing in mind to help avoid user error. Jessica suggests that in particularly important when it comes to framing your question in the clearest possible way for the user.

To overcome this, you should:

Place frames of reference at the start of questions, rather than the end

This is because the user will stop reading the question as soon as they subconsciously feel that they have the answer.

Jessica states that rather than ask the following question,

Q: Have you lived anywhere else in the past 2 years? (Y/N)

You should instead frame it like this:

In the past 2 years, have you lived anywhere else? (y/n)

This "tells the user what subset of their experience that you're interested in." So you should "front load" form questions with the important information in order to ensure that it's picked up by the user.

Check out the full article for a more detailed explanation of satisficing and how to overcome it in your form design.

Duplicate Fields

It's not uncommon to see sites that duplicate fields for email addresses and passwords in different positions in their application. Not only does this encourage users to leave, but it can also cause headaches for any users who stores passwords using a password manager.

This is because password manager typically work by hooking into the submission form events and storing field names and values.

If these password fields are given different names when the form is designed, then the password manager will be unable to populate the form as the field name doesn't match.

This is a common problem and in order to overcome it, Mammal advises you to ensure that password fields (if you really have to include two) are named identically. For sites that don't request a user password on sign up, but do request a username, Mammal recommends that you use an invisible username field when the user then goes to the site to set a password, as shown below.

Continue reading %UX Design for Passwords and Registration Forms%

Debugging Cordova Apps with DebugGap

Fr, 2015-07-17 15:00

For debugging a web application in a desktop browser, there are a myriad tools available such as Chrome’s developer tools or the Firefox firebug add on. Native application development have IDEs that provide integrated debugging tools. But hybrid applications that use a web view have always been harder to debug.

Debuggap is a tool to debug cross platform mobile apps. It’s easy to use and get started. All you need to do is download the package, include a JavaScript file and run the app on a device or emulator.

Continue reading %Debugging Cordova Apps with DebugGap%

Videos: Swift Functions

Do, 2015-07-16 20:00

In this video I show you how to create functions in Swift.

Loading the player...

Continue reading %Videos: Swift Functions%

Building a Chat Application with SignalR

Do, 2015-07-16 20:00

SignalR is an open source library for ASP.NET developers. It's the equivalent of what Socket.IO is for Node.js (if you want, you can check out a comparison on Stack Overflow). SignalR can be used to provide real-time web features to your applications. Usually, if you are into Ember and JavaScript, you might be inclined to choose Socket.IO and stick to JavaScript. One of the reasons why I chose SignalR is that it has a more extended documentation and several resources to refer to. Moreover, you can get all the benefits of ASP.NET world for free.

In this article, I’ll show you how to build a simple chat application using SignalR. If you haven’t done it yet, I suggest you to read my previous one titled "A Chat Application Using Socket.IO" in order to have a more complete overview of these topics and then compare pros and cons of both the approaches.

Continue reading %Building a Chat Application with SignalR%

Making your WordPress Plugins Developer Friendly

Do, 2015-07-16 19:00

Developers may be people with a basic level of WordPress / PHP knowledge, who want to tinker with your plugin. They may also be experienced WordPress developers who want to use your plugin to provide specific functionality to a client’s web site.

If you’d like an introduction to plugin development for WordPress, Tim Smith’s article WordPress Plugin Development is worth a read.

Why Make My WordPress Plugin Developer Friendly?

The main reason is you’ll help prevent developers from having to edit core plugin files to achieve the functionality they require.

In turn, this reduces the number of support requests and potential frustration from developers who make changes, only to find their changes are reverted in a plugin update.

Developer-friendly plugins also mean you’re more likely to get valuable feedback from more experienced developers, who may have extended your plugin’s functionality and are happy to provide their code enhancements. This allows your plugin to naturally grow, and become more stable, secure and useful to a larger audience.

There are several ways to make your WordPress plugins developer friendly, and today we’ll cover using WordPress’ Actions and Filters.

Continue reading %Making your WordPress Plugins Developer Friendly%

Problem Hunt: Solving The Problem of Finding A Problem

Do, 2015-07-16 16:14

Here’s a sentiment every entrepreneur has surely heard before: A good product solves a problem. Before Google, searching the Internet was an inefficient slog through irrelevant junk. Before the iPod, your portable music library was limited to the number of CDs you could carry. Before the flash drive, transporting large sums of data required a […]

Continue reading %Problem Hunt: Solving The Problem of Finding A Problem%

An Interview with Dave Thomas

Do, 2015-07-16 14:00

I've been listening to the Ruby Rogues and, on Episode 204, they had Dave Thomas on as guest. He was talking about Limerence and I was instantly hooked. The episode was really interesting, especially the way Dave presented the material. His views on programming languages and tools just blew me away, so I looked into more of his work. It was then that I realized, that this was the Dave Thomas who wrote "The Pragmatic Programmer" and "Programming Ruby" and cosigned "The Agile Manifesto".

Recently, I was lucky enough to interview him. Take a few minutes to learn more about this extremely influential developer and writer.

Continue reading %An Interview with Dave Thomas%

Centering With Sass

Do, 2015-07-16 14:00

Centering in CSS is well known for being a tedious task. It is kind of the running gag from the language, leading to jokes such as "we managed to send men on the moon, but we can't vertically align in CSS".

While CSS is indeed a bit tricky when dealing with centering, especially vertical centering, I feel like those jokes are a bit unfair. Actually, there are plenty ways of centering content in CSS, you just have to know how to do it.

This article is not intended to explain how these methods work, but how we can wrap them in a Sass mixin for friendly and easy usage. So if you feel a bit uncomfortable with CSS centering, may I recommend a couple of resources to read beforehand:

All good? Let's get started then.

Continue reading %Centering With Sass%

The Final Nail in the Icon Fonts Coffin?

Do, 2015-07-16 01:41

Using vector graphics as navigation icons has always made perfect sense.

But it seemed to be the arrival of the retina screen (2011-ish) that really lit a rocket under the idea.

Almost overnight icons that had looked fine on standard screens suddenly looked like they'd been brutally hacked from an old newspaper with rusty pocketknife. The minor niggles we might have had with scalable vectors suddenly seemed well worth tackling.

At the time – as the case is today – there were two ways to deliver vectors to browser and each had their pros and cons.

Web fonts vs. SVG

Although both technologies had been around for a long time, web fonts seemed to grab the early lead. Many of us were already comfortable working with fonts, and there's no doubt that plug-n-play solutions like FontAwesome made getting started that much easier.

But things have been changing over the past year or so.

While people are beginning to appreciate the power and flexibility of SVG, some of the 'gotchas' attached to icon fonts have become more apparent. These include:

  • an arcane patchwork of font-face support (and bugs)
  • positioning limitations (CSS line-height, vertical-align etc)
  • font file re-authoring overheads
  • a lack of tonal/color options

We can now add a handful of new items to that list.

A couple of weeks ago Seren Davies (@Ninjanails) gave a talk at the London Web Standards group called 'Death to Icon Fonts'. Seren is dyslexic and detailed some of the issues that icon fonts introduce to her browsing experience.

Why Are Icon Fonts and Dyslexia a Bad Mix?

Font choice has a huge bearing on readability for dyslexic users. Ironically, for all the disdain that Comic Sans has attracted over the years, it's often cited as one of the most readable typefaces for dyslexic users.

This has meant that it's very common practice for dyslexic readers to override the default font on a site with their own more readable font - perhaps something like OpenDyslexic.

And this is where we hit problems.

To speed things up, font icons are generally bundled into a single site-wide font that also contains the alphanumeric characters. The icons are placed in an undesignated 'private' section of the font.

When a user overrides this font, they replace the alphanumeric characters but there are no replacements for these custom icons. We get left with big, ugly, unhelpful empty boxes instead.

Continue reading %The Final Nail in the Icon Fonts Coffin?%

Creating a Book Club App With AngularJS, Stripe and Stamplay

Do, 2015-07-16 01:00

As a front end developer I often find myself creating rich UI’s for my side projects with frameworks like Angular and React but there comes a point where your app needs data, persistence, business logic, email and a whole host of other behaviours that are usually the domain of back-end developers. Stamplay is a service […]

Continue reading %Creating a Book Club App With AngularJS, Stripe and Stamplay%

The Best Language to Learn in 2015: Job Demand and Salaries

Mi, 2015-07-15 22:00

The last time we looked at the best programming languages to learn in 2015, JavaScript, Java, PHP and Python appeared good options when you analyze popularity on sites such as GitHub and StackOverflow.

Alternatively, perhaps we can determine the "best" technologies to learn from job-related metrics such as demand and salaries? Career planning company Gooroo examines more than 500,000 IT vacancies throughout the US, UK and Australia to produce their 2015 salaries and demand report.

Top Ten In-demand Technologies

The following technologies feature most strongly in job vacancy advertisements:

  1. Java -- featured in 18% of adverts with an average salary of $100,000 USD
  2. JavaScript -- 17%, $90,000
  3. C# -- 16%, $85,000
  4. C -- 9%, $90,000
  5. C++ -- 9%, $95,000
  6. PHP -- 7%, $75,000
  7. Python -- 5.5%, $100,000
  8. R -- 3%, $95,000
  9. Scheme -- 3%, $65,000
  10. Perl -- 3%, $100,000

These are worldwide statistics which will have a US bias owing to its larger market. C# hits the top spot in the UK (32%) while JavaScript wins in Australia (13%).

Top Ten Technology Salaries

The following technologies all pay more than $100,000, with Erlang developers earning an average of $125,000 USD per year:

  1. Erlang
  2. Clojure
  3. Haskell
  4. Lua
  5. Lisp
  6. Groovy
  7. Scala
  8. F#
  9. Ruby
  10. Python

Interestingly, only Python appears in both lists. Does that make it the best option?

Gooroo Caveats

Before you knock down your boss's door to demand a pay rise and Python re-training, Gooroo discloses:

  • Not all jobs are advertised, nor can they capture every vacancy.
  • Salary information is sparse and, when available, is often quoted as a range.
  • The data includes temporary contract and full-time permanent roles, which can offer wildly different salaries.
  • Jobs often require more than one skill. In those situations, Gooroo divides the salary by the number of skills to obtain an average for each.
  • It can be difficult to extract skills, e.g. Microsoft SQL Server could be referred to as "SQL Server", "MSSQL", "SQL 2014", etc. (On personal note, I'm yet to meet a recruiter who understands Java is not JavaScript!)

The report is interesting, contains useful information and reaches reasonable conclusions. Unfortunately, demand and salary statistics are misleading unless you appreciate the underlying data. The following issues should be noted…

Large Corporations Have a Larger Influence

Recruitment is expensive. Agencies typically charge 25% of first year salary to find suitable applicants so they can can afford to purchase adverts in online and offline media.

This explains why Java (18%) and C# (16%) feature prominently. Neither is better than competing languages but large corporations invest in them because:

  1. they have long-term business goals
  2. they employ many developers and cannot switch platforms quickly
  3. the technologies are available with support from Oracle and Microsoft.

Smaller companies may have more vacancies and similar salaries for PHP, Node.js or Ruby. However, they will be less willing or able to pay hefty recruitment fees. Their adverts are less noticeable, so the results are skewed accordingly.

Continue reading %The Best Language to Learn in 2015: Job Demand and Salaries%

Video: Conditional Flows in Python

Mi, 2015-07-15 21:00

In this short video, I'll look at how Python handles control flow. This consist of if/else combinations along with elif. I'll also see which common control flow structure Python is missing and how to get around it.

Loading the player...

Continue reading %Video: Conditional Flows in Python%

Getting Started With Vue.js

Mi, 2015-07-15 20:00

Vue.js is a JavaScript library that helps you build web applications that conform to the MVVM (Model-View-ViewModel) architectural pattern. At first glance, it might seem quite similar to AngularJS, but once you start working with it, you’ll quickly realize that Vue.js is not only much simpler and easier to learn, but definitely more flexible.

In this introductory tutorial, I’ll teach you the basic concepts of Vue.js, trying to do a complete overview of its most important features.

Adding Vue.js to Your Page

Though you can get the latest release of Vue.js from GitHub, you would find much easier to load it from a CDN. Here’s the procedure to load it from cdnjs:

Continue reading %Getting Started With Vue.js%

A Guide to Upgrading to Polymer 1.0

Mi, 2015-07-15 18:00

At the recently concluded Google IO 2015, Google released the much awaited 1.0 version of Polymer and declared it production-ready. For those of you who have been using the Polymer library while it was still in developer preview, this article will serve as a guide to migrate your existing application to the latest version of Polymer.

A few important things to note about v1.0:

  1. It is incompatible with version 0.5, the previous version and the longest surviving so far.
  2. The new release is focused on performance and efficiency while dramatically reducing the overall size of the library.
  3. It has been completely rebuilt from the ground-up to make it easier and faster for developers to design custom elements that work more like standard DOM elements.
  4. Internal benchmark tests reveal that v1.0 is about 3x faster on Chrome and 4x faster on Safari compared to the previous version.

The steps to install the latest version of Polymer remain exactly the same as described in this article. To update an existing installation of Polymer, navigate to the app directory and run the following command in your terminal:

[code language="bash"]
$ bower update
[/code]

It’s important to be aware that this will certainly break your existing app, since, as mentioned, the two versions are incompatible. Hence, installing a fresh copy in a separate folder is recommended instead. To illustrate the changes since v0.5, we’ll use the credit card custom element from one of my previous articles on SitePoint as a reference to draw comparisons between the two versions.

Polyfilling non-supporting browsers

The new version of Polymer no longer needs the shadow DOM polyfill included in the webcomponents.js library. Instead use the much smaller webcomponents-lite.js library to polyfill older browsers.

Version 0.5:

[code language="html"]

[/code]

Version 1.0:

[code language="html"]

[/code]

The “lite” version offers a size gain of approximately 80kb over its predecessor, which could be significant when performance is a key factor.

Defining custom elements

The <polymer-element> tag has been replaced by the <dom-module> tag that holds the definition of a custom element. The custom element is now identified by the id attribute of the <dom-module> tag. The rules to name the custom element still remain the same.

Version 0.5:

[code language="html"]

... [/code]

Version 1.0:

[code language="html"]

...

[/code]

Register custom elements

Previously, we could register the custom element by simply invoking the Polymer() constructor. Specifying the custom element name was optional if the <script> tag was inside the <polymer-element> tag. In this release, the custom element is now registered by using the is property on the prototype.

Version 0.5:

[code language="javascript"]
Polymer('credit-card', {});
[/code]

Version 1.0:

[code language="javascript"]
Polymer({
is: 'credit-card'
});
[/code]

The value of the is property must match the id attribute of the <dom-module> tag of the custom element and, unlike the previous release, this is not optional.

The <script> tag can be inside or outside of the <dom-module> element, but the element’s template must be parsed before the call to the Polymer constructor.

Custom element attributes

Any attribute that is part of the <polymer-element> tag should now be declared on the properties object along with the data type.

Continue reading %A Guide to Upgrading to Polymer 1.0%

WP API and OAuth – Using WordPress without WordPress

Mi, 2015-07-15 16:00

In this tutorial, we’ll learn how to install and use WP-API with OAuth - a WordPress plugin which uses REST-like API endpoints to allow reading of WP content to unauthenticated users, and writing of WP content to users who authenticate via OAuth (or via Cookies for themes and plugins).

Using the plugin isn’t very straightforward, and the prerequisite list is quite long, so this post was written to make it simple and relatively approachable (as long as you’re in control of your own server).

The tutorial assumes basic familiarity with the terminal, and with Vagrant for ease of development.

Installing

As usual, we’ll be using SitePoint’s trusty Homestead Improved instance to get a fresh environment up and running:

git clone https://github.com/swader/homestead_improved hi_wp_github cd hi_wp_github sed -i '' "s@map\: \.@map\: $PWD@g" Homestead.yaml

That last line is a shortcut that makes the current folder of the host machine shared into the VM’s Code folder. I also changed the sites block to:

sites: - map: test.app to: /home/vagrant/Code/wptest

Remember to have test.app (or the URL you choose) in your /etc/hosts file, as per instructions.

Next, we get a new instance of WP up and running. Since Homestead has MySQL pre-installed, this is a piece of cake.

cd ~/Code wget https://wordpress.org/latest.tar.gz tar -xvzf latest.tar.gz mv wordpress wptest cd wptest cp wp-config-sample.php wp-config.php

After we update wp-config.php accordingly and set up our keys and database credentials, the WP instance is ready and can be finalized by running it in the browser.

WP-API

Despite the flak it’s taken over the years (a large part of it fired from my own Dual Flak Cannons), WP really is trying to get with the times while still accommodating their old, technically inept userbase.

One such effort is the WP-API, a REST-like set of endpoints built into WP as a plugin so that the internals of a WordPress installation can become accessible to the outside. For example, getting your posts in JSON format is as simple as pinging /wp-json/posts.

Continue reading %WP API and OAuth – Using WordPress without WordPress%

Future Adaptations For Smarter Watch Screens

Mi, 2015-07-15 15:00

If smartwatches are to ever succeed in the marketplace and replace, rather than augment smartphones, the development of a more user-friendly interface is key. In this post, we'll track the evolution of the smartwatch to date, explore some of the current challenges designers face, and take a look at the future adaptations for smarter watch screens.

Continue reading %Future Adaptations For Smarter Watch Screens%

What’s New in Firefox 39

Di, 2015-07-14 22:00

July 2nd saw the release of Firefox 39. (The release was delayed a few days because of some last-minute stability issues.) Firefox has a lot to offer, but has slowly been slipping in popularity over recent years, so it's always interesting to see what Mozilla is offering to try to win us back! In this […]

Continue reading %What’s New in Firefox 39%

Video: Using CSS Stats to Remove Bloated CSS

Di, 2015-07-14 21:00

In this video I'll be reviewing a websites CSS rules to improve site performance with cssstats.com.

Loading the player...

Continue reading %Video: Using CSS Stats to Remove Bloated CSS%