Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

Perform a soft-check to see if a dependency is available...

 

Syntax

Code Block
themeRDark
languagejavascript
linenumberstrue
var available = Check(file, ver);

Parameters

ParameterTypeMandatoryNotesAPI Version
file

String

Array of String

(tick)

The name of the file to check, or an array of file names.

File name should not include path - it should just be the name and extension of the file, for example: "foo.js"

If an array is passed in, all files will be checked for the same ver (if specified).

1.0
ver

Number

Constant

(error)

The version of the dependency, or one of the following constants:

  • Check.ANY_VERSION – ignore version check
  • Check.NOT_LOADED – fail check if file(s) already loaded

Default: Check.ANY_VERSION

1.0

Return values

ValueTypeNotesAPI Version
trueBooleanThe specified requirements were met1.0
falseBooleanOne or more of the specified requirements was not met1.0

Example

Code Block
themeRDark
languagejavascript
linenumberstrue
if (Check("foo.js")) {
  // do stuff that relies on foo.js (any version)
}
 
if (Check(["bar.js", "baz.js"], 1.2)) {
  // do stuff that requires v1.2 of bar.js and v1.2 of baz.js
}
 
if (Check("foo.js", Check.NOT_LOADED)) {
  // do stuff that relies on foo.js being unavailable
}
Div
classbox
Availability
Status
colourYellow
titleBeta

Requires:

Div
classbox
Contents

Jump to:

Table of Contents
maxLevel5

Div
classbox

Dependency Checking

Overview

Topics:

Child pages (Children Display)
alltrue
depthall
pageDependency Checking
excerpttrue