14.7 ADD_LIBRARY Procedure

This procedure adds the script tag to load a JavaScript library. If a library has been added, it is not added a second time.


    p_name                    IN VARCHAR2,
    p_directory               IN VARCHAR2,
    p_version                 IN VARCHAR2 DEFAULT NULL,
    p_check_to_add_minified   IN BOOLEAN DEFAULT FALSE,
    p_skip_extension          IN BOOLEAN  DEFAULT FALSE,
    p_ie_condition            IN VARCHAR2 DEFAULT NULL,
    p_requirejs_module        IN VARCHAR2 DEFAULT NULL,
    p_requirejs_js_expression IN VARCHAR2 DEFAULT NULL,
    p_requirejs_required      IN BOOLEAN DEFAULT FALSE,
    p_key                     IN VARCHAR2 DEFAULT NULL);


Table 14-7 ADD_LIBRARY Parameters

Parameter Description


Name of the JavaScript file. Must not use .js when specifying.


Directory where JavaScript library is loaded. Must have a trailing slash.


Version identifier.


If TRUE, the procedure tests if it is appropriate to add .min extension and add it if appropriate. This is added if an application is not running in DEBUG mode, and omitted when in DEBUG mode.


If TRUE the extension .js is NOT added.


Condition which is used as Internet Explorer condition.


Module name which is used to expose the library to RequireJS.


JavaScript expression which is used to expose the library to the RequireJS module.


This has to be true if the library uses RequireJS in its code to loading other JavaScript files.


Name used to indicate if the library has already been loaded. If not specified, defaults to p_directory||p_name||p_version.


The following example includes the JavaScript library file named hammer-2.0.4.min.js (if the application has not been started from the Builder), or hammer-2.0.4.js (if the application has been started from the Builder or is running in DEBUG mode), from the directory specified by p_plugin.file_prefix. Since p_skip_extension is not specified, this defaults to .js. Also, since p_key is not specified, the key defaults to p_plugin.file_prefix||hammer-2.0.4. Hammer is a JavaScript library which exposes itself to RequireJS using hammerjs as module name.

apex_javascript.add_library (
    p_name                    => 'hammer-2.0.4#MIN#',
    p_directory               => p_plugin.file_prefix,
    p_requirejs_module        => 'hammerjs',
    p_requirejs_js_expression => 'Hammer' );