Jun 19

Dojo + Koa

By on June 19, 2015 7:03 am

Dojo and its AMD loader provide outstanding tools for structuring a Web application on the client-side. However, the notion of “writing a JavaScript application” has widened in definition over the past few years with the increased popularity of Node.js. Though Dojo can be used in a Node.js environment with the AMD module pattern, other key frameworks have gained prominence in the server-side JavaScript space, including Express, Flatiron, Sails.js and the Dojo Foundation’s very own Persevere. These frameworks give structure and handle common tasks such as routing, template rendering, and content negotiation. Still, since most operations on a Node.js server are asynchronous, server-side JavaScript can be a complex, treacherous mess of callbacks. Enter Koa, a Node.js framework that attempts to save us from this callback hell by using ECMAScript 2015 Generators. Using Dojo on the client-side and Koa on the server-side makes for a robust, clean, and expressive application. In this post, we’ll explain what generators are and how to use Koa with Dojo for ultimate code cleanliness.

Jun 17

JavaScript in the Enterprise: Where do your developers turn for JavaScript Support?

By on June 17, 2015 8:45 am

The Situation

Deadlines are looming and it looks like it’s is going to come down to the wire. A developer has hit a roadblock while trying to integrate code from another team and connect it to a third-party API. He can’t figure out where things are going wrong. Is it his code? Is it the other team’s code? Is it the API? A few hours in and he’s going in circles — with no answer in sight.

‘Who can I even ask to help me with this?’

The rest of the developers on the team are heads down trying to complete their own tasks, and googling for an answer has proven fruitless due to the number of moving parts involved.

After pinging a couple of the developers on the other team and getting the runaround, the developer is completely stuck. Due to confidentiality and the rapidly approaching deadline, going to a public forum is out of the question and, even if he could, he’s unlikely to get an answer – let alone the right answer – in time.

This leaves him with with only a couple of viable ways to solve his problem.

Option 1: Keep hacking on it and hope the answer comes.

Option 2: Escalate to a development manager who will need to stop what they’re doing, review the issue, and work to solve it.

At this point, one thing is certain, the project is delayed and multiple tasks are stopped while this bug remains at large. The developer did the best he could with what he had to work with. But what if there was an…

Option 3: SitePen Support

The developer logs into his SitePen Support account, provides the details of his issue and asks for an answer. A SitePen engineer who is familiar with the developer’s source code, reviews the issue and works with the developer to get him unstuck. Meanwhile, the rest of his team continues on their tasks, uninterrupted. The project is saved!

With SitePen Support, each developer on your team has instant access to their very own dedicated help desk, staffed by SitePen’s expert JavaScript engineers. Inevitable problems like bugs, bad implementations, questions, and indecision are constantly wreaking havoc on project timelines and there are dozens of these issues popping up, around the clock, that kill team efficiency and threaten a project’s success. Choose OPTION 3 and eliminate problems quickly and efficiently by having SitePen’s team of senior JavaScript engineers on call to extend the knowledge, manpower and expertise of your development team.

Learn how SitePen Support can help your team!

Jun 1

Multi-Platform Distribution with TypeScript

By on June 1, 2015 10:47 am

Over the past several years, JavaScript has grown to be relevant not only for rich browser applications, but also for server and console applications. Many types of JavaScript libraries can be useful on both ends of this spectrum. Dojo 2 is no exception, and one of our goals is therefore to make it as easily distributable and consumable across environments as possible.

Module Compilation in TypeScript Today

TypeScript can already help toward this goal by compiling to both the AMD and CommonJS module formats. For example, given the following simple TypeScript module:

export function myFunction() {
    // ...
May 1

SitePen Podcast – Ep. 1 The Pilot

By on May 1, 2015 2:07 pm
SitePen Podcast

At SitePen, we’ve always thought it would be fun to do a podcast, we just didn’t know what to talk about. My idea of doing a show about Fantasy Football was universally panned as were topics such as speedrunning SNES games, Birding and ‘just talk about the weather’. Finally the idea came to us, we should talk about JavaScript!

It turns out, we are all very passionate about this topic and quickly agreed! So we gave it a shot and created a podcast. Is the name the result of too many brainstorming by committee meetings? Marketing gone wrong? Or did we simply mess up the name and decide to keep it? Listen to the podcast and find out!

Let us know what you think

This episode is a pilot which means that we need to show the big studio execs that people are interested. At least I think that’s how pilots work in podcasting. I actually don’t know. Either way, let us know if you’re interested in hearing more!

Apr 16

We’re Contributing to Dojo 2!

By on April 16, 2015 2:28 pm

At the end of 2014, we looked ahead to determine where to focus SitePen’s open source efforts in the coming year. After our successful contributions to dgrid and the new dstore package, it became increasingly clear that contributing to the future of Dojo was where our team would have the biggest impact and the most fun. So, we’re happy to announce that we are and will be actively contributing to the planning and development of Dojo 2!

SitePen In Action

So far, We have contributed our knowledge and expertise in developing enterprise web applications to what Dojo 2 needs to be; a modular, collection of packages that fit together to deliver high-performance web applications that are well-designed, highly performant and maintainable.

We’ve also poured our hearts (and design resources) into the overhaul of the Dojo Website, which was in dire need of a modern design and cleaner information architecture.


So Much Excitement!

A few of the reasons we’re looking forward to contributing to Dojo 2:

  1. the final result will be a tight collection of packages that feel familiar to Dojo developers while leveraging the capabilities and improvements of the modern web platform.
  2. It’s going to be authored in TypeScript! As a superset of JavaScript, TypeScript makes it simpler to support many of the recent ES2015 improvements and provide support for types and interfaces.
  3. Helping to reshape and grow the Dojo community!

Don’t delay! Check out the new Dojo Web site, read the Dojo 2 vision and roadmap and when you’re spun up like us, hit the contribute button and tell us that you want to be part of the future of Dojo!

Mar 19

Legitimate, memory-efficient privacy with ES6 WeakMaps

By on March 19, 2015 8:06 am

When writing object-oriented source code, you generally only want to expose a very specific API to whomever is using it. In many languages you would control this by marking methods and properties you do not want other developers to use as private. However, if you have been writing JavaScript for any amount of time, you know that there is no private keyword for object properties and methods. The best option we have prior to EcmaScript6 (ES6) to protect data is to hide it inside a closure. But this comes with problems of its own, notably that data must be shared across instances, deliberately removed in order to prevent memory leaks, or new privileged methods must be allocated each time the object is instantiated. Fortunately, ES6 brings us WeakMaps, which we can use to achieve legitimate privacy without the risk of accidentally blocking garbage collection.

Mar 6

Understanding Deferreds and Promises in Dojo

By on March 6, 2015 11:18 am

It’s been a while since we’ve dove into Dojo’s Deferred module on the SitePen blog—the last time was back in 2010 when we introduced the promise-inspired improvements that landed with Dojo 1.5. Quite a lot has happened since on the topic, including a ground-up rewrite of Dojo’s asynchronous foundations in 1.8+, so it’s about time we take another look at deferreds and promises and how it all fits together in Dojo.

Feb 27

Optimized Navigation: Isomorphic Resources

By on February 27, 2015 8:14 am

When building web applications, developers often face the dilemma of whether to use traditional server-side rendered pages, or client-centric applications that rely on Ajax/JSON data requests, with client-side rendering of data. These two approaches also tend to dictate navigation (among other things), leading to traditional page navigation or a single-page application (perhaps with hash-based navigation). With the traditional approach, content is delivered in HTML form, relying on browser-driven page loads for different views. However, modern applications with more sophisticated user interfaces, often use a single-page style, controlling events, view updates, and relying on Ajax-style communication with the server to load additional content, typically in structured object format, like JSON. The traditional approach naturally works well with search engines, and browser navigation and can be quickly rendered by the browser. Single-page applications facilitate well structured user interfaces, with clean separation of presentation and data. But is there a way to combine the best of both worlds?

Feb 18

From DOH to Intern: Updating Dojo core’s tests

By on February 18, 2015 10:11 am


One of the primary motivations for creating Intern was to make support for continuous integration testing much easier to achieve with JavaScript-based application development. We recently converted the vast majority of the unit tests in Dojo core from DOH to Intern, in order to streamline the process of regression testing patches for Dojo 1.x.

This was a very large amount of work, and we learned a number of interesting things along the way that should be useful to you in writing your own tests.

JavaScript Workshops