---
title: DEF
project: jComponent V19
version: 19.194
section: reference
language: en
license: MIT
url: https://totaljs.es/docs/jcomponent-v19/19-194/reference/def/
updated: 2026-11-18T13:58:24.464Z
---

# DEF

> The configuration options of the library.

`DEF` holds the configuration of the library. Set the options in a script right after the library is loaded, before the first components start. To see how the options fit together, read [Getting started](../../guides/getting-started/).

## API

### DEF.ajaxcredentials = false

Type: `config`

Sends cookies with every request.

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

### DEF.ajaxcredentialshtml = false

Type: `config`

Also sends cookies with requests for `.html` files when `DEF.ajaxcredentials` is on.

Example: Example
```js
console.log(DEF.ajaxcredentialshtml); // false
```

### DEF.ajaxerrors = false

Type: `config`

Handles error responses as regular responses.

With `true`, the event `error` is not emitted and the Promise of a request is not rejected.

Example: Example
```js
DEF.ajaxerrors = true;
ON('request', opt => opt.throw('Failed', 500));
AJAX('GET /api/', function(response, err) {
	console.log(response, err); // Failed 500
});
```

### DEF.api = undefined

Type: `config`

The default endpoint of [DAPI()](../globals/#dapi) and [TAPI()](../globals/#tapi).

A URL, or a function that receives the name and the data and returns the value for `API()`.

Example: Example
```js
DEF.api = '/api/';
console.log(DEF.api); // /api/
```

### DEF.baseurl = ''

Type: `config`

A prefix of relative request URLs.

A string, or a function that receives the URL and returns a new one.

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

### DEF.cdn = ''

Type: `config`

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

Example: Example
```js
DEF.cdn = '//cdn.example.com';
console.log(ADAPT(null, null, '~CDN~/a.js')); // //cdn.example.com/a.js
```

### DEF.cl = {}

Type: `config`

The loaded code lists by name.

Example: Example
```js
CL_INIT('roles', next => next(['admin']), true);
console.log(DEF.cl.roles); // ["admin"]
```

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

Type: `config`

The main color of the application.

Example: Example
```js
console.log(DEF.color); // #4285F4
```

### DEF.csrf = undefined

Type: `config`

A token sent in the header `x-csrf-token`.

Requests for `.html` files do not send it.

Example: Example
```js
DEF.csrf = 'abc';
ON('request', function(opt) {
	console.log(opt.headers['x-csrf-token']); // abc
	opt.respond({});
});
AJAX('POST /api/', {}, NOOP);
```

### DEF.currencies = {}

Type: `config`

Functions that format numbers as currencies.

Example: Example
```js
DEF.currencies.eur = value => value.format(2) + ' EUR';
console.log((5).currency('eur')); // 5.00 EUR
```

### DEF.currency = undefined

Type: `config`

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

Example: Example
```js
DEF.currencies.eur = value => value.format(2) + ' EUR';
DEF.currency = 'eur';
console.log((5).currency()); // 5.00 EUR
```

### DEF.customelements = false

Type: `config`

Registers every component as its own element, `<ui-name>`.

Set it before declaring components.

Example: Example
```js
DEF.customelements = true;
COMPONENT('hello', function(self) {
	self.make = () => self.element.text('Hi');
});
console.log(customElements.get('ui-hello') != null); // true
```

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

Type: `config`

The default format of `Date.format()`.

Example: Example
```js
console.log(new Date(2024, 0, 15).format()); // 2024-01-15
```

### DEF.dateformatutc = false

Type: `config`

Formats dates in UTC.

Example: Example
```js
console.log(DEF.dateformatutc); // false
```

### DEF.decimalseparator = '.'

Type: `config`

The decimal separator of formatted numbers.

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

### DEF.delay = 555

Type: `config`

The delay in milliseconds before a request with the flag `sync` is tried again.

Example: Example
```js
console.log(DEF.delay); // 555
```

### DEF.delaybinder = 200

Type: `config`

The delay in milliseconds of delayed data bindings.

Example: Example
```js
console.log(DEF.delaybinder); // 200
```

### DEF.delaykeypress = 200

Type: `config`

The delay in milliseconds after a key press in an input.

Example: Example
```js
console.log(DEF.delaykeypress); // 200
```

### DEF.delaypref = 1000

Type: `config`

The delay in milliseconds before [PREF](../pref/) is saved.

Example: Example
```js
console.log(DEF.delaypref); // 1000
```

### DEF.delayrepeat = 2000

Type: `config`

The delay in milliseconds before a request with the flag `repeat` is sent again.

Example: Example
```js
console.log(DEF.delayrepeat); // 2000
```

### DEF.delaywatcher = 555

Type: `config`

The interval in milliseconds of the checks that wait for a value.

Example: Example
```js
console.log(DEF.delaywatcher); // 555
```

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

Type: `config`

The limits of the display sizes in pixels.

Example: Example
```js
console.log(DEF.devices.sm); // {"min":768,"max":992}
```

### DEF.dictionary = {}

Type: `config`

The translations used by [TRANSLATE()](../globals/#translate).

Example: Example
```js
LOCALIZE('hello : Ahoj');
console.log(DEF.dictionary.hello); // Ahoj
```

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

Type: `config`

The text used for an empty value in data bindings.

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

### DEF.environment = { ts, date, time }

Type: `config`

The variables of [ENV()](../globals/#env).

Example: Example
```js
console.log(DEF.environment.date); // yyyy-MM-dd
```

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

Type: `config`

The URL of components that are not declared on the page.

`{0}` is the name of the component. An empty value turns the download off.

Example: Example
```js
DEF.fallback = '';
console.log(DEF.fallback === ''); // true
```

### DEF.fallbackcache = ''

Type: `config`

How long downloaded components are cached.

Example: Example
```js
DEF.fallbackcache = '1 day';
console.log(DEF.fallbackcache); // 1 day
```

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

Type: `config`

The headers of every request.

Example: Example
```js
DEF.headers['X-App'] = 'shop';
ON('request', function(opt) {
	console.log(opt.headers['X-App']); // shop
	opt.respond({});
});
AJAX('GET /api/', NOOP);
```

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

Type: `config`

The prefix of icon names in `component.icon()`.

Example: Example
```js
console.log(DEF.iconprefix); // ti ti-
```

### DEF.importcache = 'session'

Type: `config`

How long content from `<ui-import>` is cached.

Example: Example
```js
console.log(DEF.importcache); // session
```

### DEF.jsoncompress = false

Type: `config`

The default value of the `compress` argument of [STRINGIFY()](../globals/#stringify).

Example: Example
```js
DEF.jsoncompress = true;
console.log(STRINGIFY({ a: 1, b: '' })); // {"a":1}
```

### DEF.jsonconverter = { 'text json': fn }

Type: `config`

The converters of request responses.

Example: Example
```js
console.log(typeof(DEF.jsonconverter['text json'])); // function
```

### DEF.jsondate = true

Type: `config`

Converts ISO dates to `Date` objects when JSON is parsed.

Example: Example
```js
DEF.jsondate = false;
console.log(typeof(PARSE('{"d":"2024-01-01T10:00:00.000Z"}').d)); // string
```

### DEF.keypress = true

Type: `config`

Makes inputs react while the user types.

Example: Example
```js
console.log(DEF.keypress); // true
```

### DEF.language = undefined

Type: `config`

The language added to the URL of every request.

Example: Example
```js
DEF.language = 'sk';
console.log(DEF.language); // sk
```

### DEF.languagehtml = undefined

Type: `config`

The language added to the URL of `.html` requests only.

Example: Example
```js
DEF.languagehtml = 'sk';
console.log(DEF.languagehtml); // sk
```

### DEF.languagekey = 'language'

Type: `config`

The name of the query argument with the language.

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

### DEF.localstorage = 'jc'

Type: `config`

The prefix of the keys in the browser storage.

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

### DEF.makeurl = null

Type: `config`

A function that changes the URL of every request.

Example: Example
```js
DEF.makeurl = url => url + '?v=2';
console.log(typeof(DEF.makeurl)); // function
```

### DEF.monitor = false

Type: `config`

Collects usage counters in [M.performance](../m/#performance).

Example: Example
```js
DEF.monitor = true;
SET('a', 1);
console.log(M.performance.set.count > 0); // true
```

### DEF.pathcl = 'DEF.cl.'

Type: `config`

The path behind the prefix `#`.

Example: Example
```js
console.log(DEF.pathcl); // DEF.cl.
```

### DEF.pathcommon = 'common.'

Type: `config`

The path behind the prefix `*`.

Example: Example
```js
SET('*title', 'Hello');
console.log(GET('common.title')); // Hello
```

### DEF.prefixcsscomponents = 'ui-'

Type: `config`

The CSS prefix passed to component declarations.

Example: Example
```js
console.log(DEF.prefixcsscomponents); // ui-
```

### DEF.prefixcsslibrary = 'ui-'

Type: `config`

The CSS prefix of the classes of the library.

Example: Example
```js
console.log(DEF.prefixcsslibrary); // ui-
```

### DEF.prefixcssmacros = 'm-'

Type: `config`

The CSS prefix passed to macro declarations.

Example: Example
```js
console.log(DEF.prefixcssmacros); // m-
```

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

Type: `config`

The regular expressions of the string and date helpers.

Example: Example
```js
console.log(DEF.regexp.int instanceof RegExp); // true
```

### DEF.repeatfocus = true

Type: `config`

Pauses [REPEAT()](../globals/#repeat) while the page is in the background.

Example: Example
```js
console.log(DEF.repeatfocus); // true
```

### DEF.root = ''

Type: `config`

A prefix of relative URLs that has priority over `DEF.baseurl`.

A string, or a function that receives the URL and returns a new one.

Example: Example
```js
DEF.root = '/shop';
console.log('/users/'.ROOT()); // /shop/users/
```

### DEF.scope = window

Type: `config`

The object in which paths are stored.

Example: Example
```js
console.log(DEF.scope === window); // true
```

### DEF.scrollbaranimate = true

Type: `config`

Animates custom scrollbars at the end of the content.

Example: Example
```js
console.log(DEF.scrollbaranimate); // true
```

### DEF.secret = function

Type: `config`

Sets the key that encrypts the data of requests.

Call it as `DEF.secret(key, [validator], [html])`. `validator` is a function that receives the request options and decides whether to encrypt them. With `true` as `html`, responses for `.html` files are also decrypted. The function removes itself after the first call.

Example: Example
```js
DEF.secret('my-key');
console.log(DEF.secret === undefined); // true
```

### DEF.thousandsseparator = ' '

Type: `config`

The thousands separator of formatted numbers.

Example: Example
```js
console.log((1500).format(0)); // 1 500
```

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

Type: `config`

The default time format in `DEF.environment`.

Example: Example
```js
console.log(DEF.timeformat); // HH:mm
```

### DEF.validators = { url, phone, email }

Type: `config`

The regular expressions of `String.isURL()`, `String.isPhone()` and `String.isEmail()`.

Example: Example
```js
console.log(DEF.validators.email.test('a@b.com')); // true
```

### DEF.version = ''

Type: `config`

The version added to the URL of every request.

Example: Example
```js
DEF.version = '1.2';
console.log(DEF.version); // 1.2
```

### DEF.versioncomponents = ''

Type: `config`

The version of components used without a version.

Example: Example
```js
console.log(DEF.versioncomponents === ''); // true
```

### DEF.versionhtml = undefined

Type: `config`

The version added to the URL of `.html` requests only.

Example: Example
```js
DEF.versionhtml = '1.2';
console.log(DEF.versionhtml); // 1.2
```

### DEF.versionkey = 'version'

Type: `config`

The name of the query argument with the version.

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

### DEF.webcomponentsonly = undefined

Type: `config`

With `true`, the page is searched only for the `<ui-*>` elements.

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