Book Image

Instant IntroJs

Book Image

Instant IntroJs

Overview of this book

IntroJs is a JavaScript and CSS3 library, used to create simple step-by-step help pages or introductions for websites and applications to show the users new features or whole application parts quickly and concisely. Instant IntroJs is a reference to get started with IntroJs right away. Instant IntroJs teaches you how to work with key IntroJs methods and events to create awesome step-by-step introductions. This book contains numerous examples of introductions and help pages with detailed explanations. It also shows you how to customize the library with your preferred stylesheet or integrate it with other server-side frameworks. Instant IntroJs teaches you how to work with the IntroJs API, methods, and events to create step-by-step introductions for websites and applications. This book will give you the knowledge to make the preferred changes to IntroJs in order to build a customized introduction. Instant IntroJs provides many examples of introductions and helps you with using HTML attributes and JSON configurations, as well as some descriptions about how to use and integrate IntroJs with other server-side libraries, such as Ruby on Rails and PHP Yii. You will be provided with information about the latest features of IntroJs that include multi-page introductions, creating introductions using JSON configuration and HTML attributes, methods to change or customize the library, and more. Instant IntroJs provides full and detailed examples of step-by-step introductions to help you easily learn and use the latest version of the IntroJs library.
Table of Contents (7 chapters)

Installation


In this section, we will cover the following points:

  • What are the IntroJs requirements?

  • How to download?

  • How to install?

IntroJs is a client-side library, which means all routines and events manage and execute on the client environment. All installation and running steps are related to client segments, and there is no requirement to install it on the server.

There are four simple steps to install and run IntroJs.

Step 1 – requirements

As mentioned before, to run IntroJs, there is no need to install anything on the server, and all the work is on the client side; all you need is just a web browser.

To run IntroJs, you need to have one of the following web browsers:

  • IE 8 or higher

  • Firefox 20 or higher

  • Google Chrome 26 or higher

  • Safari 5.1 or higher

  • Opera 12.1 or higher

There are some requirements for mobile or tablet browsers as well:

  • iOS Safari 3.2 or higher

  • Opera Mini 5.0-0.7 or higher

  • Android Browser 2.1 or higher

  • BlackBerry Browser 7.0 or higher

Step 2 – downloading JavaScript and CSS

To install and run IntroJs, download the latest version. All necessary files of each version should be sorted in a separated folder.

The GitHub page for IntroJs is the simplest and easiest way to download the latest version, which is available on https://github.com/usablica/intro.js/tags.

As the screenshot indicates, all versions are available in the .zip and tar.gz formats. Download the latest version. At the time of writing this book, the latest available version was 0.4.0.

Also, an unstable version is available at https://github.com/usablica/intro.js/archive/master.zip.

Note that the version under development may have some problems or bugs. It is only available for introducing the latest features, updates, and changes in the library; it won't be useful for production.

After download, extract the compressed file. It usually includes the following files and directories:

The following is an explanation for a few of these:

  • The BUILD folder is useful to build and make production files

  • The example folder includes some samples of how to use IntroJs

  • The minified folder contains the minified files that you need during production

  • The intro.js and introjs.css files are the library's main files useful for development or fixing bugs (they are not recommended for production; for production purpose, use minified files)

  • Also, component.json and package.json are package-management tools for configuration purposes

Step 3 – configuration

IntroJs can run on any HTML page by performing the following steps.

The intro.min.js and intro.min.css files are the two main files for installation that are available in the minified folder. These two files are made for the production environment. They are available in the compressed mode, and all the extra comments and descriptions have been removed from them.

There are two methods to call IntroJs files. However, it is possible to use either way, but to achieve higher speed and accuracy, the second method has been approached.

Using the <script> tag

To use the <script> tag, include the following JavaScript and CSS files in the HTML document:

  <!-- Add IntroJs -->
  <script type="text/javascript"src="intro.min.js"></script>
  <!-- Add IntroJs styles -->
  <linkhref="introjs.min.css"rel="stylesheet">

AMD and CommonJs

Another useful feature of IntroJs is its compatibility with AMD and CommonJs patterns. It is possible to call JavaScript and CSS files using these patterns, and it doesn't need to use the <script> tag. Also, by using this, it would be possible to call JavaScript and CSS files asynchronously.

This approach increases the document's loading speed, and also, the web page won't block while loading. As mentioned before, this method has been recommended instead of the other one.

require(["intro"], function(introJs) {
    //This function is called when intro.js is loaded.
    //Hence, you can write `introJs().start();` here
});

This code is written using the RequireJs library. By using this method, the scope or closure of the IntroJs program will be determined. Also, the request to load the file will be sent asynchronously, and it won't wait for the flow of calling to be finished. Moreover, it also increases the loading speed.

To use this feature, you need to have one of the following libraries in your page:

  • RequireJs

  • curl

  • LSJS

  • Dojo 1.7 or higher

Also, by using this method, it is possible to call introjs.css. However, due to the problems that this method can cause in different browsers, it is not recommended to be used, and the <link> tag has been preferred to call CSS files instead.

And that's it

By this point, you should have a working installation of IntroJs; you are now free to play around and discover more about it.