Mastering JavaScript Single Page Application Development

My book, Mastering JavaScript Single Page Application Development, is now available in both eBook and Paperback format.

JavaScript was the bane of the web development industry during the early days of the browser-rendered Internet. It now powers hugely impactful libraries such as jQuery, and JavaScript-rendered content is even indexed by many search engines.

Not only is JavaScript now more prevalent than ever in frontend architecture, but it has become a server-side language as well, thanks to the Node.js runtime. We have also seen the proliferation of document-oriented databases, such as MongoDB, which store and return JSON data. With JavaScript present throughout the development stack, the door is now open for JavaScript developers to become full-stack developers without the need to learn a traditional server-side language. Given the right tools and know-how, any JavaScript developer can create single page applications comprised entirely of the language they know best.

For more, get Mastering JavaScript Single Page Application Development (Packt Publishing, 452 pages).

real-time coding interview

I recently found myself interviewing for jobs for the first time in several years. Things have changed a bit since 2011, and the real-time or live coding interview now appears to be all the rage as a candidate screening process. This is when you are interviewed initially over the phone by someone, and then you are asked to open an online code editor app like CollabEdit, CoderPad, CodePen, or the like, and to live or real-time code your solution to one or more given problems while on the phone with the interviewer.

Continue reading

I recently had the need to find an element on a page based on its text content, but it needed to also be case-insensitive. Finding an element on the page based on its text is easy enough using the jQuery :contains() selector, but the text passed to this selector must match case, letter for letter.

Instead of modifying the functionality of a core jQuery selector, I created my own custom selector called :icontains(), where the “i” indicates case-insensitivity. I created a gist for this, shown below.

jScroll is a jQuery plugin I have developed for infinite scrolling, lazy loading, or whatever catchy phrase you may know it as. A real-world example of this behavior is your Facebook News Feed, which automatically loads content as you scroll down and reach the end of the page.

I decided to develop this plugin because I did not find any jQuery plugins out there that suited my needs precisely, or any that I could even get to work very well. For more information on jScroll and its use, please visit There is no extensive documentation at this time, as the plugin is fairly simple and was developed ad hoc. I plan to continue its development and add features, however, over an indefinite period of time.


As of version 2.0, jScroll now supports full page scrolling and auto paging once you reach the padding threshold from the bottom of the window. Window scrolling versus inside of a div scrolling is detected automatically based on the style properties of the div, i.e. if it is set to overflow “auto” or “scroll.”

Learn more at
Example use at
Download the latest version at

Like the Facebook Page for Commit Updates

Firebug‘s console object is an extremely useful tool for debugging and logging javascript interactions and responses, especially when working with AJAX and JSONP. What is not useful, is that when using the console object’s methods directly in your included javascript code, it will not work in most browsers other than Firefox, and of course it will cause errors if you (or your users) do not have Firebug installed.

Many of us have made the mistake of sometimes forgetting to delete our console code after testing and before launching our javascript to our production site, thus causing javascript errors, breaking the UI, or perhaps even breaking an entire application, depending on how javascript-dependent it is.

I aimed to solve this problem, and not just the problem of leaving the console code in my javascript by accident, but to allow it intentionally, if I wish, without breaking any browser that does not support it.

Continue reading

One thing that is not built-in to CakePHP is the ability to use search engine friendly controller and action names when those names consist of more than one word. CakePHP does an excellent job of allowing friendly URLs in general, but this typically involves single-word controller and action names. So what about controller and action names with multiple words? In CakePHP, this is handled with class names defined in CamelCase and method names defined in camelBack.

Continue reading

The following PHP coding guidelines represent my own conventions and standards which I code by, along with some CakePHP conventions when developing with CakePHP, my PHP MVC framework of choice.

These PHP coding guidelines are by no means an industry standard, nor are they intended to tell you PHP coders out there how things should be done. I simply want to share the PHP coding guidelines which I follow and enforce when working with other developers on larger projects.

Laying down some coding guidelines like these helps to provide a more structured and rapid development environment, and makes the PHP code more predictable and easier to debug.

Continue reading