The administration abundance chain, accepted for rolex replica uk its affordable accouterment and home apparatus offerings, is now peddling high-end artist accoutrement from above labels including, Chanel, uk replica watches and Zac Posen.The artist appurtenances will be awash on The Sears Marketplace through third-party vendors. The fake watches move may assume counterintuitive, but a Sears agent says it takes the administration abundance aback to its roots, which already included affairs cars.
New Pluralsight Course – Creating Custom Builds with Dojo – Failing Forward

New Pluralsight Course – Creating Custom Builds with Dojo

My latest course for Pluralsight has just been released, Creating Custom Builds with Dojo. Check it out here and all of my courses here.

If you are working on web applications with large amounts of JavaScript, you are probably working with a suite of tools in order to prepare the JavaScript, CSS, and HTML (in the form of templates) for production. If you aren’t using Dojo, you are probably using something like Grunt or Gulp to coordinate the build. Like a lot of JavaScript projects, these tools require the inclusion of many different libraries to accomplish the build. While this works well, the story for Dojo is perhaps a little more straightforward. Included in the source download (obtainable here), Dojo’s build system provides an all-in-one solution for optimizing a project for delivery to the client.

“Building” JavaScript

If, by chance, you aren’t using Grunt or Gulp, you might not be aware of what it means to “build” a JavaScript project. As you probably know, JavaScript is not compiled before being sent to the client. As such, building has a different meaning than it does for, say, an application written in C++. In this context, building means that the assets that make up the application are optimized for delivery via HTTP. Generally, this means that two things: the number of requests are minimized and the size of those requests should be as small as possible.

Types of Optimizations

For Dojo, three types of assets are optimized: JavaScript modules, HTML templates (used by custom widgets) and CSS files.

JavaScript Modules

JavaScript modules are optimized by the Dojo build system using two different techniques. First, the files are compressed or minified using one of three compression utilities: ShrinkSafe (by the Dojo Foundation), UglifyJS, or the Closure Compiler from Google. With little configuration, these tools can easily reduce the size of a JavaScript module by 30 – 60%. By taking advantage of the many options that are available in the build system and the tools themselves, even higher levels of compression are achievable.

The second method that the build system uses to optimize code is by bundling modules together into what is known as a “layer”. These are special modules that have a set of simple modules along with all of their dependencies combined into a single, AMD compliant file. When properly configured, all of the JavaScript for an application can be loaded in a single HTTP request.

HTML Templates

Many Dojo applications take advantage of the powerful widgeting framework that comes included in Dojo called Dijit. These custom widgets often involve the creation of HTML templates that form the structure of the widget. In a non-trivial application, this can lead to dozens or hundreds of HTTP calls being made. The build system handle this by detecting when a widget that is part of a layer includes a template. These templates are then built into the layer, just like all of the other dependencies so that no requests are required to load them.

CSS Files

If you have been working with client-side for any length of time, then you probably have a structure similar to this in your project:

022215_2151_NewPluralsi1

This keeps all of the files nicely organized and works for many applications. However, when using Dojo and its build system, the best approach is to do this:

022215_2151_NewPluralsi2

Notice that the CSS has been moved into the app folder. Assuming that the app folder is a Dojo package, then the build system is able to detect these files. When it discovers a CSS file, it will take two actions. First, as you might expect, the CSS is compressed and any unnecessary white space is eliminated. Additionally, the build system will look for any @import directives and, when discovered will include the imported CSS directly into the requested file. This combined bundling and minification ensures that the styling of the application is delivered in the most efficient way possible.

What is Covered?

While Dojo’s build system is well documented on Dojo Toolkit.org, it can be a bit intimidating to navigate the huge number of options that are available to tune a build to deliver an optimized experience. My Pluralsight course breaks down the build system and deals the components one at a time. Each concept of each step is introduced individually and normally accompanied by a demo that shows the impact of that specific setting. Over the two hours of the course, this provides a strong understand of each component of the system and how they integrate together. The final module even covers quite a few options that are useful in some scenarios, but might not be useful in every project.

Feel free to check the course out and let me know what you think