Versions Compared
compared with
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Excerpt |
---|
Check if a dependency is available, try and load it if not, return availability state... |
Syntax
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
var available = Check.has(file[, ver[, lazy]]) |
Parameters
Parameter | Type | Mandatory | Notes | Util.js version |
---|---|---|---|---|
file | String | Filename of dependency | 1.0 | |
ver | Number Constant | Specify the required version of the file (exact match) or a version constant:
Default: Check.ANY_VERSION | 1.0 | |
lazy | Constant | By default, Check.has() will attempt to autoload missing dependencies. If you want to prevent autoloading, specify Check.LAZY_LOAD | 1.0 |
Return Values
Value | Type | Notes | Util.js version |
---|---|---|---|
true | Boolean | The dependency check was successful. | 1.0 |
false | Boolean | The dependency check failed. | 1.0 |
<error> | Error | An error occurred, most likely invalid parameters. | 1.0 |
Example
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
function bleh() { if (Check.has("foo.js", 1.2)) { // do it the foo.js v1.2 way } else { // do it without any foo } } |
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
function bleh() {
if (Check.has("foo.js", 1.2, Check.LAZY_LOAD)) {
// do it the foo.js v1.2 way
} else {
// do it without any foo
}
} |
Notes
You can get a list of all provided dependencies using Util API diagnostics (requires Diag API).
Div | ||||||
---|---|---|---|---|---|---|
| ||||||
Availability
Requires:
|
Div | ||||
---|---|---|---|---|
| ||||
ContentsJump to:
|
Div | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
Dependency CheckingTopics:
|