Documentation for Ice 3.6. The latest release is Ice 3.7. Refer to the space directory for other releases.

Skip to end of metadata
Go to start of metadata

This page provides important information for users of the Ice for JavaScript distribution.

On this page:

Overview of the Ice for JavaScript Distribution

Ice for JavaScript is available as npm and bower packages. The following npm packages are provided for Node.js developers:

  • ice - Ice for JavaScript run time
  • slice2js - Slice-to-JavaScript compiler
  • gulp-ice-builder - Gulp plug-in to integrate slice2js with the gulp build system

The following bower package is provided for developers of browser-based applications:

Installing the Ice for JavaScript Distribution

Node.js Applications

Install the Ice for JavaScript run time libraries using npm:

 npm install ice@3.6 --save

This package also includes the browser version of Ice for JavaScript in node_modules/lib.

Browser Applications

To install with bower:

bower install ice --save 

You can also run bower install ice#master --save to get the latest patches and bug fixes.

Slice-to-JavaScript Compiler

The Slice-to-JavaScript compiler (slice2js) can be installed with this command:

npm install slice2js@3.6 --save-dev 

This command builds the compiler from source therefore you must have a supported C++ compiler installed.

In order to use slice2js on the command line, use the npm --global option to install this package.

The slice2js package includes all of the standard Slice files and automatically adds the slice directory to the include file search path.

Using Ice for JavaScript

The Ice manual provides a complete description of the JavaScript mapping.

Node.js Applications

You can use several top-level Ice package in your Node.js applications, as shown below:

var Ice      = require('ice').Ice;
var Glacier2 = require('ice').Glacier2;
var IceStorm = require('ice').IceStorm;
var IceGrid  = require('ice').IceGrid;
var communicator = Ice.initialize(process.argv);
var proxy = communicator.stringToProxy("hello:tcp -h localhost -p 10000");

Browser Applications

Add the necessary <script> tags to your html to include the Ice for JavaScript components you require.

<script src="/bower_components/ice/lib/Ice.js"></script>
<script src="/bower_components/ice/lib/Glacier2.js"></script>
<script src="/bower_components/ice/lib/IceStorm.js"></script>
<script src="/bower_components/ice/lib/IceGrid.js"></script>
<script type="text/javascript">

var communicator = Ice.initialize();
var proxy = communicator.stringToProxy("hello:ws -h localhost -p 10002");

Minified versions are available with the .min.js extension.


The Ice for JavaScript browser libraries are also available through cdnjs.

<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>

A CDN is a great option for applications that do not wish to host all of their website's files themselves. Among other things, using a CDN will help to reduce bandwidth and allow caching across multiple websites.

Note however that you will still need to serve your client JavaScript files yourself.

Slice-to-JavaScript Compiler

You can execute the Slice-to-JavaScript compiler from code as shown below:

var slice2js = require('slice2js');

If you installed the slice2js package globally, you can also run slice2js on the command line.

Refer to the manual for a description of the arguments accepted by slice2js.


Using the sample programs

The Ice sample programs are provided in a GitHub repository. You can browse this repository to see build and usage instructions for all supported programming languages. Simply clone this repository and use its 3.6 branch:

git clone -b 3.6
cd ice-demos

  • No labels