Chapter 5. StealJS

StealJS is an independent code manager and packaging tool, which allows us to load JavaScript and other file types into an application, concatenate multiple JavaScript or CSS files, and compress their content. StealJS provides cross-browser message logging, code generators, and a simple package management tool.

In this chapter, we will go through all the StealJS features.

Note

StealJS requires Java 1.6 or greater.

Dependency management

Dependency management is a tool, which provides an organized way for managing software components to work together as a one system.

The following are a few StealJS key features:

  • Loading individual files only once
  • Loading files from different domains
  • Loading JavaScript and CoffeeScript
  • Loading CSS less

We have used StealJS many times in the previous chapters. Let's have a closer look at it now.

Using StealJS, we can load files as follows:

steal(
    'file_one',
    'file_two',
    function ($) {
    
    }
);

These files are loaded in parallel and in a random order. If file_two has dependences in file_one, we can wait for file_one before starting to fetch file_two, as follows:

steal(
    'file_one').then(
    
    'file_two',
    function ($) {
    
    }
);
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.176.80