Wednesday, October 5, 2016

Create a Pokémon GO Style Augmented Reality Game With Vuforia: Part 2

Browser Trends October 2016: Microsoft Edges Downward

In September, we discussed whether the browser wars are over. October's StatCounter browser statistics provide further evidence for a slow-down…

Worldwide Desktop & Tablet Browser Statistics, August to September 2016

The following table shows browser usage movements during the past month.

Browser August September change relative
Chrome 58.44% 58.89% +0.45% +0.80%
Firefox 13.96% 13.66% -0.30% -2.10%
IE11 7.52% 7.68% +0.16% +2.10%
oldIE 2.30% 2.13% -0.17% -7.40%
Edge 2.88% 2.78% -0.10% -3.50%
Safari 4.23% 4.30% +0.07% +1.70%
iPad Safari 5.38% 5.30% -0.08% -1.50%
Opera 1.76% 1.72% -0.04% -2.30%
Others 3.53% 3.54% +0.01% +0.30%

Continue reading %Browser Trends October 2016: Microsoft Edges Downward%


by Craig Buckler via SitePoint

Scroll Indicator – An Animated Scroll Button with jQuery

Create a simple scroll indicator for your website by using css and jQuery. An animated arrow to show that content is below the fold.


by via jQuery-Plugins.net RSS Feed

How to Test React Components Using Jest

This article is by guest author Jack Franklin. SitePoint guest posts aim to bring you engaging content from prominent writers and speakers of the JavaScript community.

In this article we will take a look at using Jest, a testing framework maintained by Facebook, to test our ReactJS components. We'll look at how we can use Jest first on plain JavaScript functions, before looking at some of the features it provides out of the box specifically aimed at making testing React apps easier. It's worth noting that Jest isn't aimed specifically at React — you can use it to test any JavaScript applications. However, a couple of the features it provides come in really handy for testing user interfaces, which is why it's a great fit with React.

Sample Application

Before we can test anything, we need an application to test! Staying true to web development tradition, I've built a small todo application that we'll use as the starting point. You can find it, along with all the tests that we're about to write, on GitHub. If you'd like to play with the application to get a feel for it, you can also find a live demo online.

The application is written in ES2015, compiled using Webpack with the Babel ES2015 and React presets. I won't go into the details of the build set up, but it's all in the GitHub repo if you'd like to check it out. You'll find full instructions in the README on how to get the app running locally. If you'd like to read more, the application is built using Webpack, and I recommend "A Beginner's guide to Webpack" as a good introduction to the tool.

The entry point of the application, app/index.js, which just renders the Todos component into the HTML:

render(
  <Todos />,
  document.getElementById('app')
);

The Todos component is the main hub of the application. It contains all the state (hard coded data for this application — in reality this would likely come from an API or similar) and has code to render the two child components: Todo, which is rendered once for each todo in the state, and AddTodo, which is rendered once and provides the form for a user to add a new todo.

Because the Todos component contains all the state, it needs the Todo and AddTodo components to notify it whenever anything changes. Therefore it passes functions down into these components that they can call when some data changes, and Todos can update the state accordingly.

Finally, for now, you'll notice that all the business logic is contained in app/state-functions.js.

export function toggleDone(state, id) {...}

export function addTodo(state, todo) {...}

export function deleteTodo(state, id) {...}

These are all pure functions that take the state and some data, and return the new state. If you're unfamiliar with pure functions, they are functions that only reference data they are given and have no side effects. For more, you can read my article on A List Apart on pure functions and my article on SitePoint about pure functions and React.

If you're familiar with Redux, they are fairly similar to what Redux would call a reducer. In fact, if this application got much bigger I would consider moving into Redux for a more explicit, structured approach to data. But for this size application you'll often find that local component state and some well abstracted functions to be more than enough.

To TDD or not to TDD?

There have been many articles written on the pros and cons of Test Driven Development, where developers are expected to write the tests first, before writing the code to fix the test. The idea behind this is that by writing the test first, you have to think about the API that you're writing and it can lead to a better design. For me I find that this very much comes down to personal preference and also to the sort of thing I'm testing. I've found that for React components I like to write the components first and then add tests to the most important bits of functionality. However, if you find that writing tests first for your components fits your workflow, then you should do that. There's no hard rule here; do whatever feels best for you and your team.

Introducing Jest

Jest was first released in 2014 and although it initially garnered a lot of interest, the project was dormant for a while and not so actively worked on. However, Facebook has invested the last year into improving Jest and recently published a few releases with impressive changes that make it worth reconsidering. The only resemblance of Jest compared to the initial open source release is the name and the logo, everything else has been changed and rewritten. If you'd like to find out more about this, you can read Christoph Pojer's comment where he discusses the current state of the project.

If you've been frustrated by setting up Babel, React and JSX tests using another framework, then I definitely recommend giving Jest a try. If you've found your existing test set up to be slow, I also highly recommend Jest. It automatically runs tests in parallel, and its watch mode is able to run only tests relevant to the changed file, which is invaluable when you have a large suite of tests. It comes with JSDom configured, meaning you can write browser tests but run them through Node, can deal with asynchronous tests and has advanced features such as mocking, spies and stubs built in.

Installing and Configuring Jest

To start with we need to get Jest installed. Because we're also using Babel we'll install another couple of modules that make Jest and Babel play nicely out of the box:

npm install --save-dev babel-jest babel-polyfill babel-preset-es2015 babel-preset-react jest

You also need to have a .babelrc file with Babel configured to use any presets and plugins you need. The sample project already has this file, which looks like so:

{
  "presets": ["es2015", "react"]
}

We won't install any React testing tools yet, because we're not going to start with testing our components, but our state functions.

Jest expects to find our tests in a __tests__ folder, which has become a popular convention in the JavaScript community, and it's one we're going to stick to here. If you are not a fan of the __tests__ setup, out of the box Jest also supports finding any .test.js and .spec.js files too.

As we'll be testing our state functions, go ahead and create __tests__/state-functions.test.js.

We'll write a proper test shortly, but for now put in this dummy test, which will let us check everything's working correctly and we have Jest configured.

describe('Addition', () => {
  it('knows that 2 and 2 make 4', () => {
    expect(2 + 2).toBe(4);
  });
});

Now, head into your package.json. We need to set up npm test so that it runs Jest, and we can do that simply by setting the test script to run jest.

"scripts": {
  "test": "jest"
}

If you now run npm test locally, you should see your tests run, and pass!

PASS  __tests__/state-functions.test.js
  Addition
    ✓ knows that 2 and 2 make 4 (5ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 passed, 0 total
Time:        3.11s

If you've ever used Jasmine, or most testing frameworks, the above test code itself should be pretty familiar. Jest lets us use describe and it to nest tests as we need to. How much nesting you use is up to you; I like to nest mine so all the descriptive strings passed to describe and it read almost as a sentence.

When it comes to making actual assertions, you wrap the thing you want to test within an expect() call, before then calling an assertion on it. In this case we've used toBe. You can find a list of all the available assertions on the Jest documentation. toBe checks that the given value matches the value under test, using === to do so. We'll meet a few of Jest's assertions through this tutorial.

Continue reading %How to Test React Components Using Jest%


by Jack Franklin via SitePoint

How Can Your Site Get into Google Answer Boxes?

4 Steps to Appear in Google’s Answer Box

This article is part of an SEO series from WooRank. Thank you for supporting the partners who make SitePoint possible.

In an attempt to improve its user experience, Google is constantly developing its algorithm to display more relevant results in its search results pages (SERPs). So when someone uses a search term that looks like they are looking for an answer to a question, Google will often display a featured snippet, also known as the Answer Box. What are featured snippets? What do they mean for SEO? How do you get featured? Find out in our four-step guide to the Google Answer Box.

What Is the Google Answer Box?

The Quick Answer Box is a featured snippet that appears at the top of SERPs when Google is able to determine that searchers are looking for an answer to a question. It includes the text Google thinks answers the question, the title of the webpage that contains the content, its URL and a link.

Link juice Quick Answer Box

Featured snippets have been around for a few years now, but are becoming more prominent and common as Google is better able to figure out search intent. They are particularly common for event schedules (sports games, movie times, concerts, etc.), recipes and bacon numbers.

Pope John Paul II’s bacon number is 2, by the way.

Pope John Paul II bacon number

The Answer Box is a bit of a mixed bag, marketing wise. On the plus side, if you’re able to get your content into a featured snippet, you’ll leapfrog everyone in front of you and get your site right at the top of the SERP. On the other hand, there is some concern that answering a searcher’s question right in the search results will deter them from clicking through as they no longer have any need for visiting the page. However, pages that get picked for featured snippets have seen huge increases in both sessions and click through rate. We’ve found that positioning yourself as an authority on a subject actually encourages people, not only to click through to your page, but also to return to your site whenever they have other questions or are more likely to convert.

Step 1: Research Queries that Trigger an Answer Box

The first step to appearing in a featured snippet is to figure out what queries trigger a featured snippet. Officially, the Answer Box appears "when a user asks a question in Google Search." But that doesn’t tell the whole story. Not all searches in the form of questions trigger an Answer Box, and not all searches that display an Answer Box are in the form of a question. For example, the query “who eats the most pizza in the world” doesn’t display one:

Question query no answer box

While at the same time, searching just for "pizza popularity" triggers a featured snippet summarizing pizza’s popularity in the United States:

Pizza popularity featured snippet

Going back to our first example, searching just for "link juice" will trigger the Answer Box summarizing WooRank’s SEO Guide to link juice.

There are two ways you can go about identifying opportunities to appear in featured snippets. The first is to figure out what questions people are asking that are relevant to your keywords, and then optimize your page for the answer (more on that later). There are tools you can use like Answer the Public to find questions asked about your topic. This tool appends question-related words — who, what, when, why and how — to the front of your keyword and uses Google Suggest to create a list of questions. You can then download the list of questions as either a CSV or as an image file.

Answer the Public questions

Find questions your audience are asking outside of search engines with faqfox by WebpageFX. Faqfox crawls popular forums in a particular niche for questions asked about your keyword. If people are asking questions on reddit, they’ve probably already searched Google for them.

Do a bit of keyword research to make sure relevant questions get enough search volume to be worth the effort.

Your second option is to find your keywords that already display a featured snippet in the SERP and create content to take the current answer’s spot. This might be a little more difficult because Google’s already decided that piece of content is trusted and authoritative enough to use in an Answer Box, but it’s possible to find answers that maybe aren’t quite right for the question.

Step 2: Optimize and Structure Content to Answer Questions

Obviously, one of the most important factors in appearing in featured snippets is to write content that authoritatively answers the question. The language you use here is important — Google is looking for content that reads like the answer to a question, a how-to guide and a step-by-step process. So, if I want to get my site in the Answer Box for "what is search engine marketing," I would be sure to include a sentence that starts with “Search engine marketing is…” near the top of the page. If I wanted to be featured for “how to make the perfect pie crust," I would create a numbered list laying out each step of the process (mix flour, sugar and salt, add butter, etc.).

Once you’ve created detailed, authoritative content, optimize the rest of your page elements around the answer:

  • Title tag and <h1> tag: Normally best practice is to use your keyword in your title tag. However, to optimize for featured snippets, use the entire search query in the page title. For our two earlier examples, you’d want your title tags to look like this:

    <title>What is Search Engine Marketing?</title
    <title>How to Make the Perfect Pie Crust</title>
    
    

    Just like with traditional SEO, Google relies on the title tag to determine if the page content will answer the question. Give it a nudge in the right direction by including that question in the tag.

  • Subheads: Google doesn’t always use body text for featured snippets. Sometimes they pull subheads (<h2> through <h6>) and list them in the order they appear on the page. This is particularly common for searches looking to learn a process, how to complete a task or an answer that can be summed up in a list (like the steps to appearing in Google’s featured snippets, for example). If you’re targeting these searches, explicitly lay out each step as a separate subhead and elaborate in the body text.

  • Body copy: If you are targeting a "what is" question, use your answer in a <p> tag right after the header tag that includes the question. The ideal length for your snippet content is between 50 and 60 words (not characters, for once).

Step 3: Use Schema Markup

Semantic markup isn’t going to directly get you into featured snippets — Gary Illyes said so last year after fellow Googler John Mueller stated that schema markup does help with featured snippets. So why should you bother with it? Two reasons:

Continue reading %How Can Your Site Get into Google Answer Boxes?%


by Maria Lopez via SitePoint

Ian Fleming Publications

Website redesign for Ian Fleming Publications,


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

Dribbble Invite Giveaway

Are you looking for Dribbble Invite or you have a dribble invites to giveaway, Dribbble invite giveaway help prospects to showcase their talent. Submit your best shot and get invited.


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