---
title: DEF
project: jComponent V20
version: 20.015
section: reference
language: en
license: MIT
url: https://totaljs.es/docs/jcomponent-v20/20-015/reference/def/
updated: 2026-11-18T13:58:14.460Z
---

# DEF

> The default settings of the library.

`DEF` holds the default settings of the library. Assign the values directly after the library script, so that they apply from the start. [Getting started](../../guides/getting-started/) shows where this code belongs.

## API

### DEF.api = undefined

Type: `config`

The address used by `TAPI()`.

Returns: `String` Default: `undefined`.

Assign it to use [TAPI()](../globals/).

Example: Set the endpoint
```js
DEF.api = '/admin/api/';
console.log(DEF.api); // /admin/api/
```

### DEF.baseurl = ''

Type: `config`

The prefix that `String.ROOT()` adds to relative addresses.

Returns: `String|Function` Default: `''`.

A function receives the address and returns the final address. [DEF.root](../def/) takes priority. See [String](../string/).

Example: Prefix an address
```js
DEF.baseurl = '/app';
console.log('/users/'.ROOT()); // /app/users/
```

### DEF.cdn = ''

Type: `config`

The value of the `~CDN~` keyword in imported content.

Returns: `String` Default: `''`.

The keyword is replaced by [ADAPT()](../globals/).

Example: Use the keyword
```js
DEF.cdn = 'https://cdn.example.com';
console.log(ADAPT(null, null, '~CDN~/logo.png')); // https://cdn.example.com/logo.png
```

### DEF.cl = {}

Type: `config`

The loaded code lists.

Returns: `Object` Default: `{}`.

The path prefix `#` points here, so `#countries` is `DEF.cl.countries`. See [CL()](../globals/).

Example: Read a list through its path
```js
SET('#colors', ['red']);
console.log(DEF.cl.colors); // ["red"]
```

### DEF.color = '#4285F4'

Type: `config`

The accent colour of the app.

Returns: `String` Default: `'#4285F4'`.

[APPEARANCE()](../globals/) updates it.

Example: Change the colour
```js
APPEARANCE({ color: '#FF0000' });
console.log(DEF.color); // #FF0000
```

### DEF.currencies = {}

Type: `config`

The formatters used by `Number.currency()`.

Returns: `Object` Default: `{}`.

Each key is a currency name and each value is a function that receives the number. See [Number](../number/).

Example: Define a currency
```js
DEF.currencies.eur = function(value) {
	return value.format(2) + ' EUR';
};

console.log((10).currency('eur')); // 10.00 EUR
```

### DEF.currency = ''

Type: `config`

The default currency of `Number.currency()`.

Returns: `String` Default: `''`.

Example: Set the default currency
```js
DEF.currencies.usd = function(value) {
	return '$' + value.format(2);
};

DEF.currency = 'usd';
console.log((5).currency()); // $5.00
```

### DEF.dateformat = 'yyyy-MM-dd'

Type: `config`

The default format of `Date.format()` and of date parsing.

Returns: `String` Default: `'yyyy-MM-dd'`.

See [Date](../date/).

Example: Change the format
```js
DEF.dateformat = 'dd.MM.yyyy';
console.log(new Date(2024, 0, 15).format()); // 15.01.2024
```

### DEF.dateformatutc = false

Type: `config`

Formats all dates in UTC.

Returns: `Boolean` Default: `false`.

It applies to `Date.format()`. See [Date](../date/).

Example: Format in UTC
```js
DEF.dateformatutc = true;
console.log(new Date(Date.UTC(2024, 0, 15, 12, 30)).format('HH:mm')); // 12:30
```

### DEF.decimalseparator = '.'

Type: `config`

The decimal separator of formatted numbers.

Returns: `String` Default: `'.'`.

It is used by `Number.format()` and when numbers are parsed. See [Number](../number/).

Example: Use a decimal comma
```js
DEF.decimalseparator = ',';
console.log((1.5).format(2)); // 1,50
```

### DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }

Type: `config`

The width ranges of the device sizes.

Returns: `Object` Default: `{ xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }`.

The ranges are used by [WIDTH()](../globals/) and by the `jc-xs`, `jc-sm`, `jc-md` and `jc-lg` body classes.

Example: Read a range
```js
console.log(DEF.devices.md); // {"min":992,"max":1200}
```

### DEF.dictionary = {}

Type: `config`

The translations loaded with `LOCALIZE()`.

Returns: `Object` Default: `{}`.

See [Localization](../../guides/localization/).

Example: Read the dictionary
```js
LOCALIZE('Tabc : Hola');
console.log(DEF.dictionary.Tabc); // Hola
```

### DEF.empty = '---'

Type: `config`

The text displayed for an empty value.

Returns: `String` Default: `'---'`.

It is used by the `empty` command of [ui-bind](../ui-bind/) and by the `empty` [Tangular helper](../tangular-helpers/).

Example: Read the text
```js
console.log(DEF.empty); // ---
```

### DEF.env = { ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }

Type: `config`

The environment variables.

Returns: `Object` Default: `{ ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }`.

Variables are managed with [ENV()](../globals/). The default values can be used as date formats, for example `[ts]`.

Example: Use a variable as a date format
```js
var date = new Date(2024, 0, 15, 8, 5);
console.log(date.format('[ts]')); // 2024-01-15 - 08:05
```

### DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'

Type: `config`

The address from which unknown components are downloaded.

Returns: `String` Default: `'https://cdn.componentator.com/j-{0}.html'`.

The `{0}` keyword becomes the component name. The `source` attribute of [ui-component](../ui-component/) overrides it.

Example: Read the address
```js
console.log(DEF.fallback.format('input')); // https://cdn.componentator.com/j-input.html
```

### DEF.firstdayofweek = 1

Type: `config`

The first day of the week, for components that display a calendar.

Returns: `Number` Default: `1`.

The value `0` is Sunday and `1` is Monday. The library only stores it.

Example: Start the week on Sunday
```js
DEF.firstdayofweek = 0;
console.log(DAYS[DEF.firstdayofweek]); // Sunday
```

### DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }

Type: `config`

The headers added to every `AJAX()` request.

Returns: `Object` Default: `{ 'X-Requested-With': 'XMLHttpRequest' }`.

Example: Add a header
```js
DEF.headers['x-token'] = '123456';
console.log(DEF.headers['x-token']); // 123456
```

### DEF.iconprefix = 'ti ti-'

Type: `config`

The prefix added to icon names by `component.icon()`.

Returns: `String` Default: `'ti ti-'`.

A value that contains a space is used as it is. See [Component](../component/).

Example: Change the prefix
```html
<ui-component name="box"></ui-component>

<script>
COMPONENT('box', function(self) {
	self.make = function() {
		DEF.iconprefix = 'fa fa-';
		console.log(self.icon('home')); // fa fa-home
	};
});
</script>
```

### DEF.language = undefined

Type: `config`

The language added to the query string of every `AJAX()` request.

Returns: `String` Default: `undefined`.

The name of the parameter is in [DEF.languagekey](../def/). [ENVIRONMENT()](../globals/) can set this value.

Example: Set the language
```js
DEF.language = 'en';
console.log(DEF.language); // en
```

### DEF.languagekey = 'language'

Type: `config`

The name of the query parameter that carries the language.

Returns: `String` Default: `'language'`.

Example: Read the name
```js
console.log(DEF.languagekey); // language
```

### DEF.localstorage = 'jc'

Type: `config`

The `localStorage` key of the cache.

Returns: `String` Default: `'jc'`.

[ENVIRONMENT()](../globals/) can set this value.

Example: Read the key
```js
console.log(DEF.localstorage); // jc
```

### DEF.onstorageread = function(callback)

Type: `config`

Loads the persistent cache when the library starts.

Returns: `Function` Default: `function(callback)`.

Assign your own function directly after the library script. It must call `callback` with the stored object. The default function reads `localStorage`.

Example: Provide the stored data
```js
DEF.onstorageread = function(callback) {
	callback({});
};

ON('ready', function() {
	console.log('loaded'); // loaded
});
```

### DEF.onstoragesave = function(data)

Type: `config`

Saves the persistent cache.

Returns: `Function` Default: `function(data)`.

The function receives an object with all the items that have an expiration. The default function writes to `localStorage`.

Example: Observe saving
```js
DEF.onstoragesave = function(data) {
	console.log(Object.keys(data).length); // 1
};

ON('ready', function() {
	CACHE('filter', 1, '1 day');
});
```

### DEF.path = { common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }

Type: `config`

The targets of the short path prefixes.

Returns: `Object` Default: `{ common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }`.

`common` is the target of `*`, `cl` of `#` and `tmp` of `%`. `plugins` holds the data of plugins with a generated path. The function `DEF.path.clean(name)` returns a value without the final dot. See [Paths](../../guides/paths/).

Example: Read a prefix
```js
console.log(DEF.path.common); // common.
console.log(DEF.path.clean('common')); // common
```

### DEF.pipe = undefined

Type: `config`

The address used by `PIPE()`.

Returns: `String` Default: `undefined`.

Assign it to use [PIPE()](../globals/).

Example: Set the endpoint
```js
DEF.pipe = '/pipe/';
console.log(DEF.pipe); // /pipe/
```

### DEF.prefixcsscomponents = 'ui-'

Type: `config`

The prefix of the CSS class that a component receives as `cls`.

Returns: `String` Default: `'ui-'`.

Example: Change the prefix
```html
<ui-component name="box"></ui-component>

<script>
DEF.prefixcsscomponents = 'my-';

COMPONENT('box', function(self, config, cls) {
	console.log(cls); // my-box
});
</script>
```

### DEF.prefixcsslibrary = 'ui-'

Type: `config`

The prefix of the CSS classes created by the library.

Returns: `String` Default: `'ui-'`.

It is used by [APPEARANCE()](../globals/) and [SCROLLBAR()](../globals/).

Example: Change the prefix
```js
DEF.prefixcsslibrary = 'app-';
APPEARANCE({ dark: true });
console.log($('body').hclass('app-dark')); // true
```

### DEF.regexp = { int, float, date, pluralize, format, url, phone, email }

Type: `config`

The regular expressions used by the helpers.

Returns: `Object` Default: `{ int, float, date, pluralize, format, url, phone, email }`.

For example, `String.isEmail()` uses `DEF.regexp.email`. See [String](../string/).

Example: Validate an e-mail address
```js
console.log(DEF.regexp.email.test('info@example.com')); // true
console.log('invalid'.isEmail()); // false
```

### DEF.root = ''

Type: `config`

The prefix that `String.ROOT()` adds to every relative address.

Returns: `String|Function` Default: `''`.

It takes priority over [DEF.baseurl](../def/), and `ROOT(true)` applies only this value. See [String](../string/).

Example: Prefix an address
```js
DEF.root = '/admin';
console.log('/users/'.ROOT()); // /admin/users/
```

### DEF.scrollbaranimate = true

Type: `config`

Animates the bar of a custom scrollbar at the edges of the scrolling area.

Returns: `Boolean` Default: `true`.

See [SCROLLBAR()](../globals/).

Example: Disable the animation
```js
DEF.scrollbaranimate = false;
console.log(DEF.scrollbaranimate); // false
```

### DEF.thousandsseparator = ' '

Type: `config`

The thousands separator of formatted numbers.

Returns: `String` Default: `' '`.

It is used by `Number.format()` and when numbers are parsed. See [Number](../number/).

Example: Use a comma
```js
DEF.thousandsseparator = ',';
console.log((1234567).format(0)); // 1,234,567
```

### DEF.timeformat = 'HH:mm'

Type: `config`

The time format copied into the environment variables at startup.

Returns: `String` Default: `'HH:mm'`.

To change the format later, write the variables `time` and `ts` with [ENV()](../globals/).

Example: Read the format
```js
console.log(DEF.timeformat); // HH:mm
console.log(ENV('time')); // HH:mm
```

### DEF.tmp = {}

Type: `config`

The storage of temporary paths.

Returns: `Object` Default: `{}`.

The path prefix `%` points here, so `%form` is `DEF.tmp.form`. See [Paths](../../guides/paths/).

Example: Write a temporary value
```js
SET('%search', 'phone');
console.log(DEF.tmp.search); // phone
```

### DEF.version = undefined

Type: `config`

The version added to `.html` addresses requested with `AJAX()`.

Returns: `String` Default: `undefined`.

The name of the parameter is in [DEF.versionkey](../def/). [ENVIRONMENT()](../globals/) can set this value.

Example: Set the version
```js
DEF.version = '1.0';
console.log(DEF.version); // 1.0
```

### DEF.versionhtml = undefined

Type: `config`

The version for `.html` addresses when `DEF.version` is empty.

Returns: `String` Default: `undefined`.

Example: Set the version of HTML files
```js
DEF.versionhtml = '2';
console.log(DEF.versionhtml); // 2
```

### DEF.versionkey = 'version'

Type: `config`

The name of the query parameter that carries the version.

Returns: `String` Default: `'version'`.

Example: Read the name
```js
console.log(DEF.versionkey); // version
```

### DEF.warnings = false

Type: `config`

Prints the warnings of the library to the console.

Returns: `Boolean` Default: `false`.

Enable it during development, for example to report a method that was not found.

Example: Enable warnings
```js
DEF.warnings = true;
console.log(DEF.warnings); // true
```
