Get Started with Oracle JavaScript Extension Toolkit (JET)

Oracle JET is a collection of Oracle and open source JavaScript libraries engineered to make it as simple and efficient as possible to build client-side web apps based on JavaScript, HTML5, and CSS.

To begin using Oracle JET, you do not need more than the basics of JavaScript, HTML, and CSS. Many developers learn about these related technologies in the process of learning Oracle JET.

Oracle JET is designed to meet the following app needs:

View videos that provide an introduction to Oracle JET in the Oracle JET Videos collection.

The Oracle JET Model-View-ViewModel Architecture

Oracle JET supports the Model-View-ViewModel (MVVM) architectural design pattern.

In MVVM, the Model represents the app data, and the View is the presentation of the data. The ViewModel exposes data from the Model to the view and maintains the app's state.

A diagram illustrating the flow of data in a web application architecture. It shows the interaction between the View (UI Markup with HTML and CSS), View/Model (View Logic with JavaScript/TypeScript), and Model (Data Access with JavaScript/TypeScript) layers. The View contains Advanced Components and HTML Templates, connected by 2-way data binding. The View/Model includes Event Handlers and Data References, while the Model features REST Calls, In-Memory Cache, Data Services, and Local Storage.

Description of the illustration mvmm-arch.png

To support the MVVM design, Oracle JET is built upon a modular framework that includes a collection of third-party libraries and Oracle-provided files, scripts, and libraries.

Here’s a concise and accessible alt text for the image:

**Alt Text:**  
A flowchart diagram illustrating the architecture of a web application. It shows the client browser (with options for RequireJS/Webpack and Oracle JET Routing) connecting to web components, which interact with Oracle JET UI Components, CSS Variables, and Composite Component Arch. The view-model layer includes Abstracted Binding and Knockout. The model layer features Fetch, XHR, AJAX, and WebSocket. The server side is represented by web services returning JSON data (e.g., REST and WebSocket), with connections to a database and the internet.

Description of the illustration jet-arch.png

To implement the View layer, Oracle JET provides a collection of UI components implemented as HTML5 custom elements, ranging from basic buttons to advanced data visualization components such as charts and data grids.

Knockout.js implements the ViewModel and provides two-way data binding between the view and model layers.

Oracle JET Features

Oracle JET features include:

Oracle JET Visual Component Features

Oracle JET visual components include the following features and standards compliance:

What's Included in Oracle JET

The Oracle JET zip distribution includes Oracle JET libraries and all third party libraries that the toolkit uses.

Specifically, Oracle JET includes the following files and libraries:

Third Party Libraries Used by Oracle JET

To begin using Oracle JET, you do not need to understand more than the basics of JavaScript, HTML, and CSS or the third party libraries and technologies that Oracle JET uses. In fact, many developers learn about these related technologies in the process of learning Oracle JET.

Name Description More Information

CSS

Cascading Style Sheets

http://www.w3.org/Style/CSS

HTML5

Hypertext Markup Language 5

http://www.w3.org/TR/html5

JavaScript

Programming language

https://developer.mozilla.org/en-US/docs/Web/JavaScript/About_JavaScript

TypeScript Typed superset of JavaScript that enables you to support typechecking against the TypeScript API of JET elements and non-element classes. http://www.typescriptlang.org

jQuery

JavaScript library designed for HTML document traversal and manipulation, event handling, animation, and Ajax. jQuery includes an API that works across most browsers.

http://jquery.com

Knockout

JavaScript library that provides support for two-way data binding

http://www.knockoutjs.com

RequireJS

JavaScript file and module loader used for managing library references and lazy loading of resources. RequireJS implements the Asynchronous Module Definition (AMD) API.

RequireJS: http://www.requirejs.org

AMD API: http://requirejs.org/docs/whyamd.html

SASS

SASS (Syntactically Awesome Style Sheets) extends CSS3 and enables you to use variables, nested rules, mixins, and inline imports to customize your app’s themes. Oracle JET uses the SCSS (Sasy CSS) syntax of SASS.

http://www.sass-lang.com

If you will be using Oracle JET tooling, you may also want to familiarize yourself with the following technology.

Name Description More Information

Node.js

Open source, cross-platform runtime environment for developing server-side web apps, used by Oracle JET for package management. Node.js includes the npm command line tool.

https://nodejs.org

Create a Development Environment for Oracle JET

You can decide what development environment you want to use before you start developing Oracle JET apps. If you will use Oracle JET tooling to develop web apps, you must install the Oracle JET packages.

Choose a Development Editor

You can develop Oracle JET apps in virtually any integrated development environment (IDE) that supports JavaScript (or TypeScript), HTML5, and CSS3. However, an IDE is not required for developing Oracle JET apps, and you can use any text editor to develop your app.

You can use an IDE in conjunction with the Oracle JET command-line tooling, where you scaffold web apps by using one of the provided starter templates. You can proceed to develop the scaffolded app in the IDE of your choice by opening the project that was created using the JET tooling, in that IDE. After saving changes your app files in the IDE, you use the JET tooling to build and run the JET app.

If you are using Microsoft Visual Studio Code (VS Code) as your editor, you can add the Visual Studio Code Extension of Oracle JET Core to support developing Oracle JET apps. Specifically, the Oracle JET extension for VS Code improves developer productivity for creating clientside JavaScript or TypeScript web apps by providing:

This custom HTML data support for JET components support means that when you are editing HTML files, VS Code will prompt you with Oracle JET tags and attributes. As you start typing your Oracle JET HTML tag, a dropdown will show a list of matching choices:

A dropdown menu in a code editor interface displays options for avatar sizes, including lg, md, sm, xl, xs, xxl, and xxxs.

Description of the illustration vscode-jet-attributes.png

For more examples of Oracle JET support for VS Code, visit the Oracle JET Core Extension download page in the Visual Studio Marketplace.

Install Oracle JET Tooling

You must install Node.js to use Oracle JET tooling to develop Oracle JET apps. You’ll also need the Oracle JET CLI, ojet-cli. You can use the ojet-cli through the Node.js package runner (npx), or you can install it on your development platform.

If you already have Oracle JET tooling installed on your development platform, check that you are using the minimum versions supported by Oracle JET and upgrade as needed. For the list of minimum supported versions, see Oracle JET Support.

Install Node.js

Install Node.js on your development machine.

From a web browser, download and install one of the installers appropriate for your OS from the Node.js download page. Oracle JET recommends that you install the latest LTS version. Node.js is pre-installed on macOS, but is likely an old version, so upgrade to the latest LTS version if necessary.

After you complete installation and setup, you can enter npm commands from a command prompt to verify that your installation succeeded. For example, enter npm config list to show config settings for Node.js.

If your computer is connected to a network, such as your company's, that requires you to use a proxy server, run the following commands so that your npm installation can work successfully. This task is only required if your network requires you to use a proxy server. If, for example, you connect to the internet from your home, you may not need to perform this task.

npm config set proxy http-proxy-server-URL:proxy-port
npm config set https-proxy https-proxy-server-URL:proxy-port

Include the complete URL in the command. For example:

npm config set proxy http://my.proxyserver.com:80
npm config set https-proxy http://my.proxyserver.com:80

Use the npx NPM CLI Command

We recommend that you use the npx NPM CLI command to create and manage Oracle JET apps. With the npx NPM CLI command, you won’t need to uninstall and reinstall the NPM packages that deliver the ojet-cli if you frequently change releases of the ojet-cli.

To use npx, you must install Node.js and you must uninstall any globally installed instances of the Oracle JET CLI from your computer. To list globally-installed packages, run the npm list --depth=0 -g command in a terminal window. To uninstall a globally installed instance of the Oracle JET CLI, run the npm -g un @oracle/ojet-cli command.

Once you have installed Node.js, you can use npx and the version of the Oracle JET CLI NPM package that you want to use, plus the appropriate command. The following examples demonstrate how you create Oracle JET apps using different releases of the CLI and then serve them on your local development computer.

// Create and serve an Oracle JET 15.0.0 app
$ npx @oracle/ojet-cli@15.0.0 create myJET15app --template=navdrawer
$ cd myJET15app
$ npx @oracle/ojet-cli@15.0.0 serve

// Create and serve an Oracle JET 20.0.0 app
$ npx @oracle/ojet-cli@20.0.0 create myJETapp --template=navdrawer
$ cd myJETapp
$ npx @oracle/ojet-cli@20.0.0 serve

You can use all the Oracle JET CLI commands (create, build, serve, strip, restore, and so on) by following the syntax shown in the previous examples (npx package command).

The npx package runner fetches the necessary package (for example, @oracle/ojet-cli@20.0.0) from the NPM registry and runs it. The package is installed in a temporary cache directory, as in the following example for a Windows computer:

C:\Users\JDOE\AppData\Roaming\npm-cache\_npx

No NPM packages for the releases of the Oracle JET CLI shown in the previous examples are installed on your computer, as you will see if you run the command to list globally installed NPM packages:

$ npm list --depth=0 -g
C:\Users\JDOE\AppData\Roaming\npm
+-- json-server@0.16.3
+-- node-gyp@9.0.0
+-- typescript@4.2.3
`-- yarn@1.22.18

Use the following command to clear the temporary cache directory:

npx clear-npx-cache

To learn more about the npx NPM CLI command, see the documentation for the npm CLI. For more information about the commands that the Oracle JET CLI provides, see Understand the Web App Workflow.

Install the Oracle JET Command-Line Interface

Use npm to install the Oracle JET command-line interface (ojet-cli).

Yarn Package Manager

Oracle JET CLI supports usage of the Yarn package manager.

You must install Node.js as Oracle JET uses the npm package manager by default. However, if you install Yarn, you can use it instead of the default npm package manager by specifying the --installer=yarn parameter option when you invoke an Oracle JET command.

The --installer=yarn parameter can be used with the following Oracle JET commands:

Enter ojet help at a terminal prompt to get additional help with the Oracle JET CLI.

As an alternative to specifying the --installer=yarn parameter option for each command, add "installer": "yarn" to your Oracle JET app's oraclejetconfig.json file, as follows:

{
. . . 
  "generatorVersion": "20.0.0",
  "installer": "yarn"
}

The Oracle JET CLI then uses Yarn as the default package manager for the Oracle JET app.

For more information about the Yarn package manager, including how to install it, see Yarn's website.

Configure Oracle JET Apps for TypeScript Development

If you plan to build an Oracle JET app or Oracle JET Web Component in TypeScript, your app project requires the TypeScript type definitions that Oracle bundles with the Oracle JET NPM package.

When you install Oracle JET from NPM, the TypeScript type definitions for version 5.8.3 get installed with the JET bundle and are available for use when you develop apps. To begin app development using TypeScript, Oracle JET tooling supports scaffolding your app by using a variety of Oracle JET Starter Templates that have been optimized for TypeScript development, with the default ES6 implementation. For details, see Scaffold a Web App.

If you have already created an app and you want to switch to developing with TypeScript, you can use the Oracle JET tooling to add support for type definitions and compiler configuration. To add TypeScript version 5.8.3 to an existing app, use ojet add typescript from your app root.

ojet add typescript

When you add TypeScript support to an existing app, Oracle JET tooling installs TypeScript locally with an NPM install. The tooling also creates the tsconfig.json compiler configuration file at your app root. You can relocate the tsconfig.json file within your project by setting the optional paths.source.tsconfig subproperty in the oraclejetconfig.json file. See Properties in the oraclejetconfig.json File.

When you begin development with TypeScript, you can import TypeScript definition modules for Oracle JET custom elements, as well as non-element classes, namespaces, and interfaces. For example, in this Oracle JET app, the oj-chart import statement supports typechecking against the element’s TypeScript API.

Code snippet showing JavaScript imports and class definitions for a chart component, including ArrayDataProvider, ChartItem interface, and ViewModel class with read-only data property.

Description of the illustration full-typescript-file.png

And, your editor can leverage the definition files for imported modules to display type information.

Code snippet showing JavaScript imports, interface definition for ChartItem, class ViewModel with data array, and chart configuration for a pie chart.

Description of the illustration typescript-popup.png

Note that the naming convention for JET custom element types is changing. The type name that you specify within your TypeScript project to import a JET component's exported interface will follow one of these two naming conventions:

Until all JET component interface type names have been migrated to follow the new standard, suffix naming convention, some JET core components will continue to follow the old "oj" prefix naming convention (without the "Element" suffix). To find out the type name to specify in your TypeScript project, view the Module Usage section of the API documentation for the component.

For more information about working with TypeScript in JET, see API Reference for Oracle® JavaScript Extension Toolkit (Oracle JET) - JET In Typescript Overview.

Work with the Oracle JET Starter Templates

The Oracle JET Starter Templates provide everything you need to start working with code immediately. Use them as the starting point for your own app or to familiarize yourself with the JET components and basic structure of an Oracle JET app.

Each template is designed to work with the Oracle JET Cookbook examples and follows current best practice for app design.

You can also view a video that shows how to work with the Oracle JET Starter Templates in the Oracle JET Videos collection.

About the Starter Templates

Each template in the Starter Template collection is a single page app that is structured for modular development. The collection of available Starter Templates supports JavaScript or TypeScript development and will depend on the template type you add to your app.

Instead of storing all the app markup in the index.html file, the app uses the oj-module component to bind either a view template containing the HTML markup for the section or both the view template and JavaScript or TypeScript file that contains the viewModel for any components defined in the section.

The following code shows a portion of the index.html file in the Web Nav Drawer Starter Template that highlights the oj-module component definition. For the sake of brevity, most of the code and comments are omitted. Comments describe the purpose of each section, and you should review the full source code for accessibility and usage tips.

<!DOCTYPE html>
<html lang="en-us">
  <head>
    <title>Oracle JET Starter Template - Web Nav Drawer</title>
       ... contents omitted
  </head>
  <body class="oj-web-applayout-body">

    ... contents omitted

     <oj-module role="main" class="oj-web-applayout-max-width oj-web-applayout-content" config="[[moduleAdapter.koObservableConfig]]">
     </oj-module>
     
     ... contents omitted

    <!-- This injects script tags for the main javascript files -->
		<!-- injector:scripts -->
		<!-- endinjector -->
  </body>
</html>

The main page’s content area uses the Oracle JET oj-web-applayout-* CSS classes to manage the responsive layout. The main page’s content uses the HTML oj-module element with its role defined as main (role="main") for accessibility.

The oj-module component’s config.view attribute tells Oracle JET that the section is only defining a view template, and the view will be bound to the existing viewModel. When the oj-module element’s config.view-model attribute is defined, the app will load both the viewModel and view template with the name corresponding to the value of the config.view-model attribute.

When the oj-module element’s view and view-model attributes are missing, as in this example, the behavior will depend on the parameter specified in the config attribute’s definition.

The /js/views folder contains the view templates for the app and the /js/viewModels contains the viewModel scripts. The image below shows the Web Nav Drawer Starter Template file structure.

Here’s a concise and accessible alt text for the image:

"A screenshot of a web app navigation drawer showing a hierarchical list of modules and files, including scripts, staged themes, and view models, with a red box highlighting the 'viewModels' section containing JavaScript files."

Description of the illustration gs-qs-file-structure.png

For additional information about working with single page apps, oj-module, CoreRouter, and Knockout templates, see Create Single-Page Apps.

For details about the oj-web-applayout-* CSS classes, see Web Application Patterns. For additional information about working with responsive design, see Design Responsive Apps.

About Modifying Starter Templates

The Starter Template is the starting point for creating your apps. You can modify any Oracle JET starter template to provide a customized starting point.

You can obtain the Starter Template from the Oracle JET app that you create when you Scaffold a Web App. Load the starter template into your favorite IDE, or extract the zip file into a development folder.

If you used the command line tooling to scaffold your app, you can still use an IDE like Visual Studio Code for editing. For example, in Visual Studio Code, choose File –> Open Folder and select the folder containing the app you created. Edit your app as needed, but use the tooling commands in a terminal window to build and serve your app.

To modify the template you can remove unneeded content and add new content. Content that you add can be your own or you can reuse content from Oracle JET Cookbook samples. When you copy markup from a Cookbook sample, you copy the desired HTML and the supporting JavaScript.

Included in the code you add will be the RequireJS module dependency for the code. The app's main.js file contains the list of RequireJS modules currently included in the app. If you are using the Cookbook sample, you can determine modules that you need to add by comparing list of libraries in the app's main.js file to the list in the Cookbook sample. You will add any missing modules to the define() function in the JavaScript file for your app. For example, to add the oj-input-date-time component from the Cookbook, you would need to add the ojs/ojdatetimepicker module to the dashboard.js viewModel file since it's not already defined in dashboard.js.

To familiarize yourself with the RequireJS module to add for a Cookbook sample or for your own code, see the table at About Oracle JET Module Organization.

If you add content to a section that changes its role, then be sure to change the role associated with that section. Oracle JET uses the role definitions for accessibility, specifically WAI-ARIA landmarks. For additional information about Oracle JET and accessibility, see Develop Accessible Oracle JET Apps.

Modify Starter Template Content

To add content, modify the appropriate view template and ViewModel script (if it exists) for the section that you want to update. Add any needed RequireJS modules to the ViewModel’s define() definition, along with functions to define your ViewModel.

The example below uses the Web Nav Drawer Starter Template, but you can use the same process on any of the Starter Templates.

Before you Begin:

To modify the Starter Template content:

  1. In your app's index.html file, locate the oj-module element for the section you want to modify and identify the template and optional ViewModel script.

    In the Web Nav Drawer Starter Template, the oj-module element is using the config attribute. The following code sample shows the mainContent HTML oj-module definition in index.html, where the moduleAdapter observable, a ModuleAdapterClass object, obtains the configuration from its koObservableConfig field.

    <oj-module role="main" class="oj-web-applayout-max-width oj-web-applayout-content"
               config="[[moduleAdapter.koObservableConfig]]">
    </oj-module>

    The return value of the [[moduleAdapter.koObservableConfig]] observable is set to the current state of the CoreRouter object. The CoreRouter object is defined with an initial value of dashboard in the app's appController.js script, where the page initially loads and no path is yet specified, as shown in the navData array below for the empty path case. The router object is created from the array and then passed to the moduleAdapter declaration.

        let navData = [
       { path: '', redirect: 'dashboard' },
       { path: 'dashboard', detail: { label: 'Dashboard', iconClass: 'oj-ux-ico-bar-chart' } },
       { path: 'incidents', detail: { label: 'Incidents', iconClass: 'oj-ux-ico-fire' } },
       { path: 'customers', detail: { label: 'Customers', iconClass: 'oj-ux-ico-contact-group' } },
       { path: 'about', detail: { label: 'About', iconClass: 'oj-ux-ico-information-s' } }
    ];
    
    // Router setup
    let router = new CoreRouter(navData, {
      urlAdapter: new UrlParamAdapter()
    });
    router.sync();
    
    this.moduleAdapter = new ModuleRouterAdapter(router);
    this.selection = new KnockoutRouterAdapter(router);

    The navigation data provider for oj-navigation-list element is created as an ArrayDataProvider object that associates the available navData routes by using the slice(1) function to remove the first path definition in the navdata array that specifically handles the "empty path" case.

    // Setup the navDataProvider with the routes, excluding the first redirected route.
    this.navDataProvider = new ArrayDataProvider(navData.slice(1), {keyAttributes: "path"});

    To modify the starter templates, for example, the Dashboard Content Area, you will modify both dashboard.html and dashboard.js.

  2. To modify the view template, remove unneeded content, and add the new content to the view template file.

    For example, if you are working with an Oracle JET Cookbook sample, you can copy the markup into the view template you identified in the previous step (dashboard.html). Replace everything after the <h1>Dashboard Content Area</h1> markup in the template with the markup from the sample.

    The following code shows the modified markup if you replace the existing content with a portion of the content from the Date and Time Pickers demo.

    <div id="div1">
      <oj-label for="dateTime">Default</oj-label>
      <oj-input-date-time id="dateTime" value='{​{value}​}'>
      </oj-input-date-time>
          
    <br/><br/>
          
      <span class="oj-label">Current component value is:</span>
      <span><oj-bind-text value="[[value]]"></oj-bind-text></span>
          
    </div>
  3. To modify the ViewModel, remove unneeded content, and add the new content as needed. Include any additional RequireJS modules that your new content may need.

    The app's main.js file contains the list of RequireJS modules currently included in the app. Compare the list of libraries with the list you need for your app, and add any missing modules to your define() function in the ViewModel script. For example, to use the oj-input-date-time element shown in the demo and to use the IntlConverterUtils namespace API, add ojs/ojdatetimepicker and add ojs/ojconverterutils-i18n modules to the dashboard.js ViewModel script since it's not already defined in dashboard.js.

    The sample below shows a portion of the modified dashboard.js file, with the changes highlighted in bold.

    define(['knockout', 'ojs/ojconverterutils-i18n', 'ojs/ojknockout', 'ojs/ojdatetimepicker', 'ojs/ojlabel'
       ], function(ko, ConverterUtilsI18n) {
       /**
        * The view model for the main content view template
        */
      function DashboardViewModel() {
        var self = this;
        self.value = ko.observable(ConverterUtilsI18n.IntlConverterUtils.dateToLocalIso(new Date(2020, 0, 1)));
      }
    
      return DashboardViewModel;
    });
    In this example, you are not copying the entire code section. The Cookbook uses a require() call to load and use the needed libraries in a single bootstrap file. The Starter Template that you are pasting uses define() to create a RequireJS module that can be used by other parts of your app.
  4. If you want to add, change, or delete modules or templates in the app, modify the main.js RequireJS bootstrap file and appController.js file as needed. The appController.js file also contains the event handler that responds when a user clicks one of the navigation items. Depending upon your modifications, you may need to update this method as well.

  5. Verify the changes in your favorite browser.

    The following image shows the runtime view of the Web Nav Drawer Starter Template with the new Dashboard Content Area content showing oj-input-date-time with its current value.

    Oracle Dashboard interface showing the Dashboard Content Area with a default date and time of 12/20/2020, 11:00 AM and a current component value of 2020-12-20T10:00:00Z.

    Description of the illustration gs-quickstart-runtime.png

Work with the Oracle JET Cookbook

The Oracle JET Cookbook is a valuable resource for you to use as you develop apps. It includes an implementation of each JET component, along with samples that demonstrate how to implement common usage patterns using one or more of the JET components.

Each Oracle JET Cookbook demo includes a brief introduction, the demo implementation, and, following the implementation, tabs (Info, demo.html, and so on) that describe how to implement the demo, show the source HTML, JavaScript/TypeScript, and, where applicable, the CSS and JSON.

Effective use of the cookbook will make your development task easier. You can, for example, copy code from the cookbook to your own apps, or you can modify code directly in your browser and click Apply Changes to preview changes in your browser.

Overview of JET Cookbook UI

Optimize App Startup Using Oracle CDN and Oracle JET Libraries

You can configure the Oracle JET app to minimize the network load at app startup through the use of Oracle Content Delivery Network (CDN) and the Oracle JET distributions that the CDN supports.

When your production app supports users who access the app from diverse geographical locations, you can perform a significant performance optimization by configuring the Oracle JET app to access Oracle CDN as its source for loading the required Oracle JET libraries and modules. Oracle maintains its CDN with the libraries and modules that are specific to a given Oracle JET release. The CDN support for each release is analogous to the way Oracle JET tooling also supports copying these files into the local src folder of the app for a particular release. In both cases, access to the appropriate libraries and modules is automated for the app developer. You configure the app to determine where you want the app to load the libraries and modules from.

After you create your app, the app is configured by default to load the needed libraries and modules from the local src folder. This allows you to create the app without the requirement for network access. Then, when you are ready to test in a staging environment or to move to production, you can configure the Oracle JET app to use CDN server replication to reduce the network load that occurs when users access the app at the start of a browser session. When the user initially starts the app in their browser, Oracle CDN ensures a distributed server closest to the geographic location of the user is used to deliver the app's needed third party libraries and Oracle JET modules to the user's browser.

Configuring the app to load from CDN offers these advantages over loading from the app src folder:

Configuring your app to reference the bundles configuration on Oracle CDN is recommended because Oracle maintains the configuration for each release. By pointing your app to the current bundles configuration, you will ensure that your app runs with the latest supported library and module versions. For information about how to enable this bundle loading optimization, see About Configuring the App for Oracle CDN Optimization.