Wednesday, June 1, 2016

Browser Trends June 2016: Microsoft Misfortune

Mozilla finally overtook Microsoft during April 2016. Do the latest StatCounter browser statistics hold any cheer for IE and Edge?…

Worldwide Desktop & Tablet Browser Statistics, April to May 2016

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

Browser April May change relative
Chrome 56.89% 57.07% +0.18% +0.30%
Firefox 14.24% 14.50% +0.26% +1.80%
IE11 9.02% 8.65% -0.37% -4.10%
oldIE 3.11% 2.73% -0.38% -12.20%
Edge 2.10% 2.29% +0.19% +9.00%
Safari 4.20% 4.32% +0.12% +2.90%
iPad Safari 5.26% 5.35% +0.09% +1.70%
Opera 1.83% 1.80% -0.03% -1.60%
Others 3.35% 3.29% -0.06% -1.80%

Continue reading %Browser Trends June 2016: Microsoft Misfortune%


by Craig Buckler via SitePoint

Nitpicking over Code Standards with Nitpick CI

There are many ways to make sure your code respects a given code standard - we've covered several before. But enforcing a standard team-wide and making sure everyone knows about mistakes before they're applied to the project isn't something that's very easy to do. Travis and Jenkins can both be configured to do these checks, but aren't as easygoing about it as the solution we're about to look at: Nitpick CI.

Some Nitpick landing page icons

Nitpick CI is a dead simple single-click tool for making sure submitted Github pull requests adhere to the PSR-2 standard. Unfortunately, Nitpick currently only works with these two specific (but popular) vectors - only Github, and only PSR-2. It's free for open source projects, so let's give it a try.

Bootstrapping

To test Nitpick, we'll create a brand new repository based on thephpleague/skeleton and pretend we're building a new PHP package. The skeleton already respects PSR-2, so it's a perfect candidate for an invalid PR. Feel free to follow along!

git clone http://ift.tt/1fO247l nitpick-test
cd nitpick-test
find . -type f -print0 | xargs -0 sed -i 's/:author_name/Bruno Skvorc/g'
find . -type f -print0 | xargs -0 sed -i 's/:author_usernamename/swader/g'
find . -type f -print0 | xargs -0 sed -i 's/:author_website/http:\/\/bitfalls.com/g'
find . -type f -print0 | xargs -0 sed -i 's/:author_email/bruno@skvorc.me/g'
find . -type f -print0 | xargs -0 sed -i 's/:vendor/sitepoint/g'
find . -type f -print0 | xargs -0 sed -i 's/:package_name/nitpick-test/g'
find . -type f -print0 | xargs -0 sed -i 's/:package_description/nitpick-test package for a SitePoint tutorial/g'
rm CONDUCT.md
rm -rf .git

The above commands clone the skeleton, replace placeholder values with real values, and delete some files we don't need. The project is now ready to be committed and pushed online (as long as you created a repo on Github).

Continue reading %Nitpicking over Code Standards with Nitpick CI%


by Bruno Skvorc via SitePoint

The Beginner’s Guide to Content Strategy

Everybody seems to be in love with content marketing these days. From traditional industries, to the smallest and most nimble of startups, marketers from all walks of industry say they plan to invest more in content in 2016 and beyond.

B2C Content Marketing Trends

Image Source

However, for many, content marketing remains perplexing. Understanding the basic logic is easy, but structuring your effort to get tangible results for your business is a whole different story.

[author_more]

If you are one of those looking to explore content marketing for your business, but not sure where to get started, our guide to content strategy will come in handy. We’ll cover everything you need to get started step by step.

The first and most important thing is to understand why you want to invest in content.

Define the Business Rationale

Many think all it takes to do this type of marketing is… to produce content. But before you even think about writing your first blog post, you have to be very clear about the business reasons for engaging in content marketing.

Defining your business rationale is what differentiates content marketing and blogging.

What are some of the business aspects you have to think through?

Why use content?

Why are you creating content in the first place and what do you hope to achieve with it? Many business owners set out, thinking their efforts in producing content will lead to direct sales, finding themselves disappointed when that doesn’t happen at scale.

Building trust is key in content marketing. Think of it as a long-term strategy that builds your general reputation and creates a bond with your audience that gets stronger as time goes by.

What is your unique proposition (competitive advantage)?

What is the one thing your business is offering that none of your competitors can hope to replicate? It could be anything from a superior product to having staff that are both extremely knowledgeable about your business and always willing to go above and beyond in helping your clients.

Building your content strategy around your competitive advantage is useful for your business, as over time your audience will come to associate your business with it.

Think of brands like Buffer and HelpScout and how they’ve tied what they want to be known for (superior customer service) to the content they produce, the topics they write on, and even the voice and tone they project across their communication channels.

What are your goals with content marketing?

Finally for this stage, think hard about the concrete business goals you want to achieve with content marketing. Here are some of the goals people typically have for content:

  • Raise awareness about company and product
  • Build a reputation
  • Generate leads for a salesforce to work with
  • Help in nurturing leads during sales cycle
  • Educate potential or existing clients on how to use product/service to increase adoption/retention levels
  • Generate new sales

Typically, your content strategy should focus on one or two of these goals. If you go beyond that, you risk becoming too unfocused in your efforts.

Figuring out how you are going to measure your progress is very important in this stage. After you come up with your high-level goals, spend some time to complement them with a set of key performance indicators (or KPIs) that you will be tracking.

To get a feel for what this whole step looks like in practice, here’s an example:

Most content marketing strategies are aimed at generating leads for the business they’re operating under. In the last few years, people have found that the most effective way to do this is by collecting emails, so we’ve seen an explosion in so-called ‘email harvesting techniques’ around the web (when was the last time you visited a website and weren’t asked for your email?).

If your content strategy falls under the same category, a good KPI to track is the size of your email list.

Now that you are done with the initial stages of your content marketing strategy, you are ready to dive deep into figuring out its technical details.

Figure Out Your Target Audience

Every content strategy should start with the audience. Every piece of content that you create as part of this strategy will be aimed at a specific audience. If you don’t know who this is, your efforts will fall flat because they will not be targeted.

Your content audience might be different from your existing customer base (especially if you want to target a new market segment with your content), but your current customers are a good place to start.

Create marketing personas

Marketing personas (sometimes also called ‘customer avatars’) are a great tool for marketers. Use them to create a stylized version of your dream customer/reader and keep them in mind when creating your content.

These avatars are great because they serve a two-fold purpose:

  • They keep your whole organization on the same page — by looking at your avatar, every member of the team will know who it is they’re talking to — this will help you keep a consistent message and tone across all interactions with this given customer.
  • They help you humanize your voice — when you have a clear picture of who you’re producing for, it is much easier to be talking like a human.

Buffer has a great resource to help you get started with your customer avatars.

What are the needs of your audience?

Now that you have a clear understanding of your ideal audience member(s), figure out what their needs and pains are.

Creating content around those is the surest way to make a mark, attract your audience, and build trust with them (only if you can demonstrate your ability to solve those pains).

What is the buyer’s journey for your reader/customer?

The final element of discovering your audience is to get an excellent understanding of what the Buyer’s Journey looks like for your prospects. The main stages in this, as formulated by Hubspot, are Awareness, Consideration, and Decision.

The Buyer's Journey

Source

Think about the topics and questions your audience has in each of these stages, and also where they would go to get these answered. The findings in this stage of the creation of your strategy will guide your decisions about what topic to produce content on and how to distribute it.

Now that you know why you want to use content marketing, and who it is you want to target with it, you can move to the implementation stage of your strategy. It starts with reviewing what content you have already produced and how well it serves the audience you want to reach.

Audit Your Existing Content

You could be thinking that as a beginner, this is a step you can legitimately skip. That might very well be the case, if you’ve just started your business and you don’t have a website yet.

If your company has been around for a while, and you have a website (even if it doesn’t contain a ‘Blog’ section), you already have some existing content. You need to have a clear understanding of where this content fits in your general strategy.

Perform a content audit and tie your existing content to the business goals, your audience, and the buyer’s journey — all of which we’ve discussed above.

If you already have experience with content marketing and have put some effort in it, a tool such as the content matrix, as described by Buffer, might be useful in order to understand which pieces are performing well, which need to be improved, and which should be scrapped altogether.

Content Matrix

Find Topics to Produce Content For

Too many marketers start here and skip the steps described in the previous sections. Next, they find themselves struggling to find meaningful topics or see little benefit from their energetic efforts to produce content.

Hopefully, if you’ve take the time to apply the methods for audience discovery, creating a strategy, and a plan to implement it, you’ll find this step much less challenging.

You’d still need to put in the time and effort though, if you are to find the topics your audience wants to consume.

Know the language of your audience

First of all, you need to know very well not just what problems your potential buyers want to have solved, but also how they talk about them. Using a language your audience understands is just as important as knowing the topics they care about.

Fortunately, there are numerous places online where you can meet your readers. Quora is one great place and a great tool for research, but there are many topical discussion forums, Reddit directories, and so on that you can use for research.

Do keyword research

SEO and organic traffic still play an important role in content marketing. It would be a grave mistake to ignore them.

Another mistake many marketers still make is to focus only on the most popular (and hence competitive) keywords. Plenty of evidence exists suggesting that long-tail keywords get a lot of traffic and are much easier to rank for:

Search Engine Keyword Demand

Image Source

Spending enough time on Quora, Reddit, and other similar forums will give you knowledge about the main terms people in your target audience use to talk about the topics they care about. It may even give you some ideas about concrete topics and questions you’d like to answer with your content.

However, once you know the general topics, you can use Google’s Keyword Planner, as well as sites like Ubersuggest and KeywordTool.io to discover long-tail keywords around the same topics.

Spy on your competitors

When thinking about competitors, you shouldn’t limit yourself to other companies offering the exact same product (or service) as you, but rather focus on everyone who’s aiming at the same audience and fighting for the same dollar as you. For example, if you’re a company offering support and tweaking for WordPress sites as a service (like WPCurve for example), your competition includes pretty much every freelance WordPress developer on Upwork.

Take the time to find out who your true competitors are. Take the top 5–10 keywords you’d want to rank for on Google and do an anonymized search to see who the top performers currently are. Analyze the top 10–20 search results carefully to see what they’re doing right and get ideas for your own content.

Keep an eye on what content your competitors are putting out on a regular basis (use feedly to keep everything in one place). While at it, create a control group of companies that are doing great with content marketing, such that you’d like to emulate with your own content, and read and analyze everything they publish.

If you need some inspiration, here are some of my favorites:

Continue reading %The Beginner’s Guide to Content Strategy%


by Ilia Markov via SitePoint

Harnessing the Google Maps JavaScript API the Right Way

Google Maps icon

Google Maps is an online mapping service providing up-to-date road maps, business listings, directions, street-level photos and more.

There are notable alternatives to Google Maps, such as Mapbox and Open Street Map. But in my view, none of the competitors can match up to Google Maps for the sole reason of the completeness of its business directory. Google is able to present a complete and vast map equipped with up-to-date business details, thanks mainly to the crossover with their search offering.

There are various APIs for interacting with Maps, from the simple Static API to the powerful JavaScript API, which is the focus of this article.

Of course, you can place Google Maps on your site without leveraging the various APIs on offer. This makes life easier, of course, and still offers a lot of useful features. But the Maps JavaScript API gives us full control over our map for performance and customization purposes.

Google Maps JavaScript API

In this article, I'd like to show you how to make the most of the Maps JavaScript API --- using it the right way.

There are lots of tutorials and examples already out there for this, but too often without a focus on the best way of achieving the desired result. They get things done quickly, but without a considered approach or explanation of why certain steps have been taken.

The complete source code for this article can be found on our GitHub repo.

Creating a Basic Map Canvas

The first thing we need to do is set up a simple front-end framework for building the mapping application.

Create the HTML

Let's create an HTML file with the following markup:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Google Maps API Template</title>

    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div id="map"></div>

    <script src="script.js" defer></script>
  </body>
</html>

This gives us a robust platform for building a full mapping application.

Notice how we've used the defer attribute for our script. This tells the browser to download the specified scripts as soon as possible, but to wait until HTML parsing has finished before executing them. It's important to use defer whenever possible, as it will prevent the rendering of the page from halting before it's finished in order to execute JavaScript code --- providing a janky loading experience for the user. The eagle-eyed reader may notice how we haven't included Google Maps' JavaScript: this is deliberate, and will be explained shortly!

Build the on-ready callback

Now, let's set up our initial JavaScript file, script.js, starting with the document.addEventListener('DOMContentLoaded', function () {}) call:

document.addEventListener('DOMContentLoaded', function () {
  if (document.querySelectorAll('#map').length > 0)
  {
    if (document.querySelector('html').lang)
      lang = document.querySelector('html').lang;
    else
      lang = 'en';

    var js_file = document.createElement('script');
    js_file.type = 'text/javascript';
    js_file.src = 'http://ift.tt/1TKijCN' + lang;
    document.getElementsByTagName('head')[0].appendChild(js_file);
  }
});

The #map length check is a quick way to find out if a certain element is present on the current page. Quite often, the same external JavaScript file will be included on an entire website, and quite often some portions of code are only required for certain pages. In this instance, we only ever want to execute this code if we're presenting a map canvas to the user. This prevents unnecessary code bloat on pages that don't require it. (Performance matters!)

Once we're sure we have a map canvas on the page, we may think we're ready to proceed, but there's one more check we should perform. By default, the Google Maps JavaScript API loads in English, regardless of what language the requesting page is in. A great way to counteract this is to set a lang variable based on the lang attribute in the <html> element. This will allow us to include the Google Maps JS in the correct language for our user. This is especially useful for multilingual (i18n) websites that include the same script.js file across all languages.

Grabbing Google's JavaScript file

Now comes the time to load the external Google Maps JS file. The reason we've left it until now, rather than including it as a regular <script> tag in the HTML, is to prevent unnecessary code bloat in pages that don't have a map canvas. To load in the file, we create a new <script> element and inject it into the <head> of the DOM. As Google's API handles callbacks for us, we don't need to do anything more fancy than this:

var js_file = document.createElement('script');
js_file.type = 'text/javascript';
js_file.src = 'http://ift.tt/283Qf74' + lang;
document.getElementsByTagName('head')[0].appendChild(js_file);

There are a few interesting things to note in the query string parameters passed to the API.

Firstly, we pass our lang variable as the language parameter to instruct Google on which language we want the map to be in.

Secondly, we provide the signed_in parameter as true. This is to increase the personalization of the map (e.g. it will have your starred locations visible, amongst other things).

Next, we pass the key parameter with our API key (more on that shortly).

Finally, and most importantly, we specify our callback function using the callback parameter. This tells Google which of our functions it should trigger once the file has been fetched successfully.

Google Maps JS API will still work without a valid key parameter. However, we would be issued with a JavaScript error console warning message. So we should make sure we get ourselves a free API key by following Google's guide.

Initializing the map canvas

Now that we've got our initialization function call set up, we can move on to defining our callback function initMap(). This is the function that the Google Maps JS API will trigger once it's successfully loaded.

var map;

function initMap() {
  map = new google.maps.Map(document.getElementById('map'), {
    center: {lat: -34.397, lng: 150.644},
    zoom: 8
  });
}

When creating a new Google Map, it's best to create the variable for the map in the global scope (outside of any functions) so that it's easier to interact with the map later. This is why we define map outside of initMap().

Now that we've got an empty map variable to work with, we can go ahead and assign the Google Map object to it inside the initMap() function. This is exactly as Google's Simple Map example. One important thing to note is that we must specify both a center and a zoom, or the map will not initialize at all. There is no default!

Don't forget the CSS

One last important step to getting the initial basic map canvas to function is to provide some CSS in our style.css file:

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

#map {
  height: 100%;
}

The most common pitfall we'll cover today is forgetting to set a height attribute for the #canvas element. Regardless of everything else covered in this article, if there's no height (or min-height) CSS attribute set, we won't see a map at all. The styles applied to <html> and <body> are only there to allow the canvas to be full-screen.

Google map without markers

Continue reading %Harnessing the Google Maps JavaScript API the Right Way%


by Jamie Shields via SitePoint

Java 8 Streams: An Intro to Filter, Map and Reduce Operations

After shying away from them for years, Java finally embraced functional programming constructs in the spring of 2014. Java 8 includes support for lambda expressions, and offers a powerful Streams API which allows you to work with sequences of elements, such as lists and arrays, in a whole new way.

In this tutorial, I'm going to show you how to create streams and then transform them using three widely used higher-order methods named map, filter and reduce.

Creating a Stream

As you can tell from its name, a stream is just a sequence of items. Although there are lots of approaches to stream creation, for now, we'll be focusing only on generating streams from lists and arrays.

[author_more]

In Java 8, every class which implements the java.util.Collection interface has a stream method which allows you to convert its instances into Stream objects. Therefore, it's trivially easy to convert any list into a stream. Here's an example which converts an ArrayList of Integer objects into a Stream:

// Create an ArrayList
List<Integer> myList = new ArrayList<Integer>();
myList.add(1);
myList.add(5);
myList.add(8);

// Convert it into a Stream
Stream<Integer> myStream = myList.stream();

If you prefer arrays over lists, you can use the stream method available in the Arrays class to convert any array into a stream. Here's another example:

// Create an array
Integer[] myArray = {1, 5, 8};

// Convert it into a Stream
Stream<Integer> myStream = Arrays.stream(myArray);

Continue reading %Java 8 Streams: An Intro to Filter, Map and Reduce Operations%


by Ashraff Hathibelagal via SitePoint

What’s Next for EdgeHTML

[author_more]

This article is part of a web development series from Microsoft. Thank you for supporting the partners who make SitePoint possible.

We've been immersing ourselves in your feedback, reviewing development trends, and meeting with partners and developers around the globe to inform where we take EdgeHTML next. In this session we'll take you through our plans for 2016, starting with our upcoming release and concluding with some longer-term investigations and investments in the future of the web platform.

This article is part of the web development series from Microsoft tech evangelists and engineers on practical JavaScript learning, open source projects, and interoperability best practices including Microsoft Edge browser and the new EdgeHTML rendering engine.

We encourage you to test across browsers and devices including Microsoft Edge – the default browser for Windows 10 – with free tools on dev.microsoftedge.com, including status.microsoftedge.com, a portal for the latest implementation status and future roadmap for interoperable web platform features in Microsoft Edge and other browsers, including Internet Explorer. Also,  visit the Edge blog to stay updated and informed from Microsoft developers and experts.

Continue reading %What’s Next for EdgeHTML%


by Microsoft Developers via SitePoint

A Real World Example of WordPress Plugin Development

To make the most out of this tutorial, you should have a basic understanding of topics such as actions, filters, shortcodes, widgets and object orientated design.

If you're interested in brushing up on the basics, you can read my previous article An Introduction to WordPress Plugin Development. It will help you to build a solid understanding of the concepts and ideas we'll be using throughout this tutorial.

Continue reading %A Real World Example of WordPress Plugin Development%


by Simon Codrington via SitePoint