What Is Node.js And Why Should I Care? [web Development]

featured-nodeJavaScript is a just a client-side programming language that runs in the browser, right? Not any more. Node.js is a way of running JavaScript on the server; but it’s so much more as well. If you’re at all interested in web development, you really should find out a little about Node and why it’s making waves in the community.

What is Node.js?

Node is an interface to the V8 JavaScript runtime – the super-fast JavaScript interpreter that runs in the Chrome browser. As it happens, you can also download V8 and embed it into anything; Node does that, for web servers. JavaScript is after all, just a language – there’s nothing that says it couldn’t be used on a server as well as in the user’s browser. In a typical LAMP server stack, you have an underlying Apache or NGINX web server, with PHP running on top of it. Each new connection to the server spawns a new thread, and it’s very easy to quickly lose performance or for a site to “go down” – the only way to support more users being to add more servers. It simply doesn’t scale well. With Node, this isn’t the case. There is no Apache to listen for incoming connections and return HTTP status codes – you’ll need to handle that core server architecture yourself. Luckily, there’s modules to make this easier, but it can still be a little overwhelming when you start out. The result, however, is a high performance web application.

Klout - a social statistics web app built upon Node.js for high performance
Klout – a social statistics web app built upon Node.js for high performance

JavaScript is an event-based language, so anything that happens on the server triggers a non-blocking event. Each new connection fires an event; data being received from an upload form fires a data-received event; requesting data from the database fires an event. In practice, this means a Node site will never lock up and can support tens of thousands of concurrent users. Node.js plays the role of the server – Apache – and interprets the application code being run on top of it. Just like Apache, there are various modules (libraries) that can installed to add features and functionality – like data stores, Zip file support, Facebook login, or payment gateways. Of course, there aren’t nearly as many as for PHP, but Node is still in it’s early stages and there’s a strong community behind it. A core concept of Node is asyncronous functions – so everything runs in the background, basically. With most server side scripting languages, the program has to wait whilst each function completes before going on to the next. With Node, you specify functions that should be run on completion of something else, while the rest of your app moves on. It’s a complex topic that I won’t go into too much depth today, but one of those characteristics that defines Node, so it’s important to grasp it. Enough chat though – here’s a Hello World example HTTP server to give a quick idea of some of these concepts.

  var http = require("http");   http.createServer(function (request, response) {   response.writeHead(200, {   'Content-Type': 'text/plain'   });   response.write('Hello World!');   response.end();  }).listen(8080);  console.log("Server running!");  

Let’s try to break that down. First, we’re including the http module in the project. We’re then creating a server and passing in an anonymous function as a parameter – this function will be called for every new connection that’s made. It takes two arguments – request, containing the request parameters from the user; and response, which we’ll use to send things back. Next, we’re using the response object to write a header back to the user with the response HTTP code 200 (“ok”) and content type, writing a “Hello World!” message, and ending the response. Finally, we tell the server to listen on port 8080 for incoming requests, and output a quick message to the console (the command line) to let us know it’s running. If you want to actually try this for yourself, save the above code as test.js, download the Node installer, and from the command line run –

node test.js

Open up a browser and navigate to localhost:8080 to see your test app! You should now have a little idea of how this whole asynchronous thing works, along with event driven models. If you’re new to JavaScript, the concept of passing around functions as arguments to other functions is probably a little strange.

Why use Node?

Firstly, for performance and scalability. Node is fast. That’s a pretty important requirement when you’re a start-up trying to make the next big thing and want to make sure you can scale quickly, coping with an influx of users as your site grows. Node is also perfect for offering a RESTful API – a web service which takes a few input parameters and passes a little data back – simple data manipulation without a huge amount of computation. Node can handle thousands of these concurrently where PHP would just collapse. Performance benefits and scalability aside, there’s a good chance you already know some JavaScript, so why bother learning a whole new language like PHP? And then – there’s the excitement of learning something new and relatively uncharted. You know when something new arrives and then becomes so ubiquitous that you regret not learning it earlier, forever playing catchup? Don’t do that this time. Node is going to be big.


Like most new technologies, it’s not that easy to deploy Node on existing hosts. If you have a shared web hosting, you can’t simply upload a Node app and expect it to work. VPS and dedicated servers are better positioned – you can install Node on them. Even easier is to use a scalable service like Heroku, which is completely free to develop your site on – you only need to pay when you need more resources. I gave an example of using Heroku before when we used it to create a Facebook fangate, but it can be used for Node too. On the other hand, it’s very easy to install Node locally onto your Windows, Mac or Linux PC and begin developing immediately – just head over to Download Node. It’s also important to note that Node is not simply a replacement for Apache – existing web applications are not compatible, and you’ll be working effectively from scratch (though there are a lot of frameworks out there to help you with common features).  The other major downside to node is that it’s still in the early stages of development, meaning some features are likely to change as development progresses. In fact, if you look at the documentation, it includes a stability index, which shows how risky use of each feature is currently. stability You know – it’s never been a more exciting time to be a web developer. With open web services and data exchange, it’s easier than ever to make something awesome. Are you think of learning Node? Good. Go forth and make the next Twitter! You’ll probably also want a good grounding of the Javascript jQuery library for the front end.

5 Fears You Can Destroy Today To Become A Kickass Blogger

Can you write a blog? Without knowing you, I can tell you the answer is probably yes.

Ever since their debut at the beginning of the millennium, blogs have been an integral part of what we consider as “the Internet”. Starting as a simple way to record and share your thoughts and experiences, blogs have developed into something much bigger: a full-blown alternative to printed newspapers and magazines.

Unlike newspapers, though, absolutely anyone can write a blog. Yes, even you. It takes almost no effort to set up your own blog, and once you do, you’re left with the really easy part: writing it. Think you can’t? Continue reading. When you’re done, consider again.

Why Should I Even Blog?


Well, if you have absolutely no interest in writing anything, maybe you shouldn’t. If you’re reading this, though, you probably do. Everyone has something to say, and almost anything you have to say can benefit someone.

What do you do for a living? Are there many blogs out there that deal with this field? Whether you’re a mechanic, a car dealer, a florist, or even a programmer, there’s room for a blog about your profession. What’s more, your industry will benefit from this — sharing ideas with the community can contribute greatly to your field.

This is true for hobbies as well. Love wood working? Horseback riding? Puzzle solving? Politics? No matter what it is you do, there’s a vast community out there that shares your interests, and just like you can learn from them, they can learn from you. Blogs and forums are part of what makes a community alive, and being an integral part of your community will benefit both you and the other members.

You don’t have to sit on the sidelines. You can take an active role and show others what you know. All you have to do is kick these fears aside.

I’m Not A Good Enough Writer

That may be the case, but there’s only one way to become a good writer: writing. If you think all the famous bloggers out there were incredible writers the moment they opened their first blog, you’re wrong. Take your favorite blog and try going back to the very first posts. Are they as good, as polished as the newer ones?

It’s true that you may not become super successful as long as your writing is not very good. You’d be surprised, however, at how little many people care about a mistake here and there as long as you keep providing  interesting and useful information. If your chosen subject is a visual one, you may not be required to write a whole lot, in which case your audience may not even notice an error here and there.

You should, of course, work on getting better. Listen to comments, read other blogs, and keep writing — your skills will improve along the way.

No One Cares About What I Have To Say


The biggest fear (or excuse) any budding blogger has is that no one would read their blog. And you know what? In the beginning, no one will. Unlike writing for a big established blog or a newspaper, starting your own blog will not get you instant exposure. But that doesn’t mean no one cares about what you have to say. It only means no one knows you’re saying it yet.

The same rule applies here: as long as you keep providing interesting and useful information, no matter what you’re writing about, someone is going to care about it. After all, the Web is full of blogs about anything from being a waiter to Dr. Who. Somebody’s reading them.

If you’re planning on writing a personal blog, let your friends know about it. If what you have to say is interesting only to your family and friends, you have your readers right there. If it’s interesting to others as well, your friends will start sharing your posts and things will get rolling from there. If you’re writing about a certain subject, start connecting with others in the same community and show them your blog as a way of sharing ideas.

The most important thing is to keep going. No new blog is successful overnight. If you quit after a week or a month, don’t expect much. You have to keep at it. If you’re providing good content, someone will read it.

What’s So Special About Me?

What’s so special about me? Why are you reading this post right now? You’re not doing it because I’m special. You’re doing it because this post is online. Were you to write something I was interested in, I would probably be reading your post right now.

So the short answer to this question is: nothing. And yet, you’re the only you out there. You’re the only one with this exact mix of knowledge, expertise, opinions and thoughts. Yes, the really big names are really big for a reason — they know so much about their field, it becomes a privilege to learn from them. But trust me, even Seth Godin is not the only person in the world who knows what he knows. He’s just the only one sharing it in just that way.

Have something to write about? It’s already special enough. So why not do it?

I Might Make Mistakes


Yes, you might. And everyone makes them. It doesn’t kill you. I’ve made mistakes. I’m still here. Yes, it can be embarrassing, but as long as you don’t make them in every single post (and if you do, you may want to switch to a topic you know more about — there’s bound to be one), and as long as you learn from them and don’t get angry and resent those who correct you, you’ll be fine.

Besides, not every blog is about conveying information to others. If you don’t feel like an expert in anything, just start writing about your personal experiences and thoughts. Who knows, you may actually gain that expertise along the way.

People Will Attack Me In The Comments

If people attack you, they must be reading your blog. And you know what? That’s a good thing. If people are reading your blog, there’s no way around angry and hurtful comments. They will come. And at first, they’ll get to you. They’ll make you doubt yourself. They’ll make you sad. They’ll make you want to quit writing. But you won’t.

The first rule about Internet trolls: ignore them. It’s also the second, third and fourth rule. Don’t argue with them. Don’t let them get to you. The more of these comments you get, the easier it will become. And don’t forget, comments mean you have an audience. And for every troll that comments, there are probably 50 other readers who don’t. Enjoy it!

If you’re having a really hard time with trolls, we’ve assembled a complete toolkit for dealing with them. It comes in three parts: part 1, part 2, part 3. Use it.

Are You Ready?

Ready to conquer your fears? It’s time to set up your own blog. Whether you choose to self-host your blog or go for an easier solution such as WordPress, Blogger or Tumblr, you can be done in no time. If you’ve decided to set up a blog following this post, I would love to get a link to it once it’s ready.

And don’t forget: do what you’re good at and keep doing it. Results will follow.

Have you been thinking about setting up your own blog? What’s been stopping you? What fears did you have to conquer to start your own blog? Share your thoughts below.

Image credit: Wesley Fryer, Why Blog image via Shutterstock, Thomas Hawk, Auntie P

How To Turn WordPress Into A Life Stream Of All Your Online Blogs

wordpress lifestreamFor most of us, the amount of digital content we produce is staggering – Twitter, personal blogs, professional blogs – but bringing all of that in to one central place is a real challenge. Having recently purchased my own vanity domain of jamesbruce.me to act as a central hub for my articles and web content, the task fell upon me to find a suitable way to aggregate it all – commonly called a life stream.

Flavors.me is a great ready-made way to do that, but it isn’t perfect for my needs and certainly doesn’t demonstrate any skills beyond signing up for a free service. I’d also much rather host something on my own server, as the perils of placing your trust in web services has often been tested. Today I’m going to walk you through how to create your own WordPress lifestream, and if you follow along with the tutorial, you should end up with something not dissimilar to this:

wordpress lifestream

It’s a freely available theme, and clicking on any post will take you to the original source.

So what are my requirements?

  • Runs on WordPress. Given that I try to market myself as a WordPress guru and consultant, doing it it on any other platform would just be embarrassing. I should be able to demonstrate that WordPress is quite capable of doing what I want.
  • Aggregates various feeds, automatically and without my input.
  • Doesn’t duplicate content, but instead links back to the original article. This is very important, and I’ll explain it later.
  • Uses images where available – nothing is more boring than a wall of text.

Duplicate Content Issue

The problem with a lot of WordPress RSS-aggregator plugins is that they copy the entire content of the original and create a page that is considered a duplicate by Google, thereby labelling you a dirty rotten content-thief. Serious efforts have been made by Google this year to remove and de-rank those websites that copy other peoples work and try to pass it off as their own – often called spam blogs – but any legitimate attempts by you to republish your own work in its entirety are going to fall foul of the same fate.

To mitigate this, I’ve found a fantastic plugin that still pulls content into your blog to give the freedom that WordPress allows, but also changes the permalink structure of the articles to point directly to their original source.

You Will Need

  • The Shaken Grid Lite free theme – you must supply a valid email to which the download link will be sent, but it’ll send a separate email asking you to subscribe to the email list, which you can ignore if you wish.
  • The Feed WordPress Plugin, which will handle pulling in all the content automatically and adjusting permalinks.
  • YD FeedWordpress Content Filter, which will import images so we can use them locally.
  • This file which I wrote to fix the issue of featured images not being set by Feed WordPress – rename it to loop.php and replace the same file in your Shaken Grid Lite theme directory. If the featured thumbnail isn’t available, it will use the first attached image file. Feed WordPress will automatically download and attach the media item in the RSS feed, but it doesn’t create the featured image. This solves that problem.
  • FTP access to your site, or the ability to edit theme files.
  • A variety of RSS feeds you wish to aggregate.
  • A decent webhost that isn’t going to disable your account if you use a little power. Feed aggregator plugins are notorious for annoying shared web hosts, but we’ll try to minimize the impact. If you’re at the point where you’re hosting a number of your own successful blogs though, perhaps it’s about time you looked at upgrading to your own virtual server.


Install and activate FeedWordPress, then the YD Content Filter plugin through the standard Plugins -> Add New interface, and upload and activate the Shaken Grid Lite theme.

There should now be a Syndication section on the admin sidebar. Expand it, and I’ll walk you through the options to set up on each screen.


  • This is where you add feed sources. Enter the URL in the box – either a direct feed URL or just a general website address.

wordpress life stream

  • It’ll then validate your feed, or give a choice of feeds that it auto-discovered.

wordpress life stream

Feed & Update Settings

  • By default, your feeds won’t update automatically, so change that setting here under the Update Scheduling option. Set it to update after a page load, and leave it at the default 60 minutes.

wordpress life stream

Post & Links

  • Double check so that under the Links option, the Permalink points to the copy on the original website.

wordpress lifestream theme

  • Disable comments and pings too.

wordpress lifestream theme

You can safely leave the rest of the options alone.

  • The YD FeedWordpress options should be under your regular Settings tab on the sidebar. Click on that, and make sure that the option to Import Images as Local Attachments is enabled.

wordpress lifestream

Theme Adjustments

If you check out your page now, you’ll notice that images aren’t displaying correctly and the full article is being shown instead of just a short snippet. To solve this, download the file I mentioned earlier and navigate to the Shaken Grid Lite theme directory through FTP. Replace the loop.php with the one supplied (rename it to loop.php obviously). Alternatively, if you’re unable to access FTP but can edit the files through WordPress, copy and paste the contents instead.

Assuming the feeds you’ve imported are actually providing featured images, they should now be showing on your homepage. If they aren’t, it’s out of the scope of this article to fix your website, but let us know if you’re having problems in the comments and perhaps we could check your feed for you.

That’s it, you should be well on your way now to having all your published content aggregated. Don’t forget you can still post regular articles on the blog too – they’ll appear alongside and mixed in with the rest, but clicking on them will take you to the full version just like a regular blog would. Happy life-streaming!

How To Make Sure Your WordPress Blog Is Accessible To Mobile Users

Don’t make your readers zoom-in on their phone: offer a mobile version of your WordPress blog. Here’s how.

When it comes to running a blog, the first thing you need to think about is your visitors. A key question you should ask yourself: do you want your blog to be easy to access on the go? If the answer is yes, then you need to ensure that your website renders as beautifully on a smartphone as it does on a desktop computer – and everything in between.

There are a few ways you can make your website mobile or tablet-ready. Whether it’s a responsive WordPress theme that adapts to different devices or a WordPress plugin that allows you to create a dedicated mobile version, the options below have you covered.

The best thing about these solutions is that they require absolutely no coding knowledge whatsoever. You can have a mobile site up and running in minutes, without having to know anything about designing or coding websites.

Responsive Themes

The easiest and most efficient way to make your WordPress blog mobile friendly is by choosing a responsive theme. Responsive themes automatically adapt to whatever device you happen to be using when visiting a site. So if you’re on a computer with a smaller screen, the site adjusts to the size of that screen. If you’re on a smartphone, it will automatically display a mobile theme.

Using a responsive theme is convenient because you don’t have to rely on third party plugs or additional fixes, and the all-in-one solution makes life much easier. So where do you find decent responsive themes?

If you’re looking for a paid theme, Themeforest has over 2,000 responsive themes to choose from. If you’d rather opt for a free theme, there are quite a few to choose from. We’ve featured some great responsive portfolio themes, for example.


Responsive themes aren’t great just if you want to create a portfolio website. This list of over 250 responsive themes shows you the sheer variety available – and all the themes listed are free.

Also be sure to check out Dessign’s impressive set of responsive themes, a few of which are quite reminiscent of Squarespace‘s style.


If you’ve already invested time, effort or money into your WordPress theme and don’t want to make the switch to a responsive theme to make your site mobile-friendly, you can opt for a plugin instead. The disadvantage , however, to using a plugin is that you lose the personality of your blog that you may have chosen with its theme, and will have to make-do with the style the plugin provides.

An important feature that all of these plugins offer is to allow viewers to switch to the desktop site, if they choose to.

One of the most popular plugins we’ve come across is WPTouch. We reviewed the plugin a few years ago, and the look and feel of the plugin’s theme hasn’t changed much. WPTouch is a plug-and-play plugin, meaning there is nothing that you have to do to get your visitors seeing a mobile version of your site. You can, however, tweak the settings and customize the icons used in the mobile version of your site. If we had one complaint about the plugin it’s that its appearance hasn’t changed at all over the years – so it looks a little dated.

This is how your site looks with WPTouch activated:


Mobile Detector is another great plugin and boasts detection by over 5,000 mobile devices. The plugin also offers a variety of themes to choose from. Some of these themes are sleek, minimal and modern, giving this a leg up on WPTouch. Best of all: it offers the mobile versions of WordPress’ official themes, Twenty Eleven and Twenty Twelve. The WZ Mobile Theme is another great option that allows you to display your featured images on the home page.

This is how your site looks with Mobile Detector activated, with the WZ Mobile Theme:


UppSite distinguishes itself from other similar plugins by displaying a landing page that gives visitors the choice, the first time they load your site, to browse the mobile (HTML5) or desktop version of your site. It can also save their selection. It’s also  one of the plugins that you have to choose some settings for, before it shows up on your blog. As you’re setting up, you can choose what kind of site you’re running – a blog, a business site, or a combination.

As you explore the settings, you’ll find that UppSite is a pretty feature-rich plugin. As you’re setting up the plugin, you can choose your icon, the text that goes with it, and its colour.

After you’ve set up the plugin,there are other customization options but some of them are limited to the premium version of the plugin. The free version allows you to change the background of your mobile page and the top bar, among other things.  With the premium version, you also get a downloadable iOS, Android and Windows Phone app, and can customize your landing page – but all that will set you back a whopping $99.99 a month.

This is how your mobile site looks with UppSite activated:


Of all of these plugins, if we had to choose one, it would be Mobile Detector. It gets the job done in a minimal amount of steps. If you need something a little bit more robust, which you want more control over for your business site, UppSite might be better suited to your needs – if you can afford it.

Extra Tools

Another way to make sure that you’re WordPress blog is completely mobile-accessible is by using the free tool Embed Responsively. This tool allows you to embed YouTube videos, Instagram photos and videos, Google Maps and more, all while ensuring that the embed stays within the confines of your design. You’ll find that with some embeds images or videos can overlap content. Embed Responsively puts an end to these kinks.

To find out more about Embed Responsively, check out our in-depth review.

Which Should You Choose?

If you want to offer your visitors a seamless experience where the design of your website in a desktop browser extends to the design in a mobile browser, you should choose a responsive theme. This will also make life easier for you, taking away the need to update plugins that may eventually no longer be supported.

If you want to have more control over how your viewers see your website in its mobile version, and want to think about extra details like monetization and engagement, a plugin is probably best for you.

Do you have any tips or tricks on how to make sure your WordPress blog is mobile-ready? Let us know in the comments.

Image Credit: Luc Legay

WordPress Just Got A JSON API. Here’s Why This Matters

WordPress started off as a humble blogging platform, and somehow found itself becoming a fully-fledged content management system that powers a significant proportion of the Internet, including this very website. Despite that, WordPress has a number of notable limitations, including a proper API.

Well, that’s not quite true. Of course, for many years WordPress has had an XML-based Application Programming Interface (API) that allowed developers to create third party applications that interact with WordPress. But XML is horrible. It’s slow to parse. It’s hard to read. It’s astonishingly verbose. JSON is much, much better. It’s quick to parse, more human-friendly and has rapidly became the language of choice for API developers.

For a while now, developers have been crying out for a JSON API for WordPress. This would make it drastically simpler to create third-party applications and websites that interact with WordPress-based websites in a way that is modern, and supported across a wide variety of languages and platforms.

After almost eleven years of waiting, their prayers have been answered. The (snappily named) JSON REST API plugin has been in the works for a while now, and has finally reached version 1.0. This means that it’s reached a feature completeness, and has a level of stability that makes it ready for production environments. What’s more, the functionality of this Plugin will soon be integrated with WordPress core, with it expected to be introduced fully by WordPress 4.0. It really is the future.

This is a milestone release of a major plugin, and one with significant promise for developers, site owners and consumers alike. Convinced? Here’s how you can start using it today.

Installing The Plugin

There are a plethora of plugins that promise to make it easy to add a JSON API to WordPress. However, none of them are as polished and complete as the official, genuine article.


When you head into the Plugin browser in WordPress, make sure you download the one that says ‘JSON REST API (WP API)’ and is by Ryan McCue, who is a member of the WordPress core team. This article only address that specific plugin.

Interacting With The API

Once installed, the WordPress JSON API will be exposed under the http://yourdomain.com/wp-json/ directory. Any queries to the API must be sent here, and can made by sending a simple HTTP request through your web browser, or through a HTTP library in your favorite programming language. The next few demonstrations of the API will be pretty much focused upon the usage of the API. We’re going to be querying it through the web browser, although in the real world you’ll probably end up using something like Python’s venerable Requests library, or CURL.

Simple enough. But we’ve still not discussed how to query the API. As I’m sure you guessed, the WordPress API is phenomenally huge. I mean, WordPress is huge. It’s a project of gargantuan size, consisting of millions of lines of code and thousands of contributors. There’s no way we can cover the API in its entirety in a single blog post. If you’re interested in reading further to this API, you’d be best having a look at the documentation, which is simultaneously comprehensive, yet also surprisingly easy to read.

One more thing. I’ve installed the JSONView plugin for the purposes of making the outputted text a bit more readable. This plugin is free, and is available for Chrome and Firefox.

So, let’s start. First, let’s see the various types of queries we can make against the JSON API. Open your browser and navigate to http://yourdomain/wp-json/.


As you can see, this comprehensively shows the actions you can make against the JSON API, and includes adding and manipulating user data, adding posts and viewing posts that have already been posted. Handily, this shows which requests require variables being passed, as well as the HTTP methods that can be used against them.

But let’s move on. Here you can see we’ve navigated to a view showing all posts that have been published. Not only do you get the posts themselves, but a significant amount of metadata for each post.


If you want to select an individual post, you you just need to add a forward-slash and the numerical ID of the post.


You can also compose search queries through the API, allowing you to bring back posts that match a specific query. This is done by sending a HTTP request to http://yourdomain.com/wp-json/posts?filter[s]=query.


You can also access and update user information through the API. Although, it’s worth noting you need to be authenticated. This is reassuring, as an API can often be an avenue to information disclosure and security breaches.


So, why does this matter?

Firstly, it means that it’s never been easier for developers to integrate their applications with the WordPress platform. Expect to see some highly impressive mobile applications and websites springing up around the WordPress platform. Also, expect WordPress clients to find their ways to niche mobile computing platforms, such as Blackberry 10 and Firefox OS.


We can also unlock the data retained within our WordPress sites without having to manually perform database queries, use the much (and justifiably) maligned XML-RPC based API, or writing complicated web-scraper programs using a platform like Scraperwiki.

Furthermore, it suggests that WordPress is moving away from being a platform used exclusively for blogging and content management, and has a vision of becoming a tool for creating more complex and ambitious products, as indicated by the inclusion of an extensible, JSON API that will eventually find its way to WordPress core. One might think that it’s gunning for Django.

Are You Excited?

But what do you think? Are you a developer? Excited about being able to access WordPress with a JSON API, or think it’s a waste of time? Are you a consumer and excited about seeing WordPress integrating with more products and services? Let me know your thoughts in the comments below.

Photo Credits: Give Me JSON Or Give Me Death (Ed Summers), WordPress Logo (Phil Oakley)