# 10. __Components__

[![+Professional Support](https://www.totaljs.com/img/badge-support.svg)](https://www.totaljs.com/support/) [![+Chat with contributors](https://www.totaljs.com/img/badge-chat.svg)](https://messenger.totaljs.com)

I have prepared a lot of UI components and you can found they here:

- __Free UI components:__ [__www.componentator.com__](https://componentator.com)
- [Download source-code](https://github.com/totaljs/components)
- [Download pre-compiled HTML components](https://github.com/totaljs/components/0cdn/)
- [jComponent use __KeyCDN__](https://www.keycdn.com/?a=41841)

## Import components

I have prepared __CDN with all components__. So you can import components which you are really need. Components are always up-to-date.

- [__GitHub repository__ with pre-compiled components](https://github.com/totaljs/components/tree/master/0cdn)
- __CDN__: <https://cdn.componentator.com>
- __CDN__ contains files with lower-case file names
- each file is a HTML file which can contains styles, scripts and inline HTML

### Import via `<link rel="import"`

```html
<head>
	<link rel="import" href="https://cdn.componentator.com/j-textbox.html" />
	<link rel="import" href="https://cdn.componentator.com/j-textarea.html" />
	<link rel="import" href="https://cdn.componentator.com/j-dropdown.html" />
</head>
```

### Import via `IMPORT()`

```javascript
IMPORT('https://cdn.componentator.com/j-textbox.html');
IMPORT('https://cdn.componentator.com/j-textarea.html');
IMPORT('https://cdn.componentator.com/j-dropdown.html');

// With a specific version
IMPORT('https://cdn.componentator.com/j-textbox@1.html');

// Cached
IMPORTCACHE('https://cdn.componentator.com/j-textbox.html', '5 minutes');
IMPORTCACHE('https://cdn.componentator.com/j-textarea.html', '5 minutes');
IMPORTCACHE('https://cdn.componentator.com/j-dropdown.html', '5 minutes');
```

### Fallback for non exist components

jComponent __+v14__ supports a fallback for non-exist components. The fallback URL is specific in `MAIN.defaults.fallback` property and it's directed on __Componentator CDN__ provided on [__KeyCDN__](https://www.keycdn.com/?a=41841).

- [__Live example__ on jsFiddle](https://jsfiddle.net/petersirka/3aozf5Ld/)

```javascript
DEF.fallback = 'https://cdn.componentator.com/j-{0}.html';
// Default value
// jComponent replaces {0} for a component name

DEF.fallbackcache = '2 days';
// Cache fallback components for 2 days
// Components will be cached in localStorage
```

If the compiler doesn't find some component then it tries to download it according to the `fallback` URL. If the `fallback` won't contain any URL then __import fallback__ will be disabled.

---

All components are under __MIT license__.