# Load parts of a page with ui-import

> Fetch an HTML part from the server into an element with ui-import or IMPORT(), and let the part carry its own components.

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: 7ac2231a7f413cd4d9e85011909290452b95eae379496c91fab2f1b18347f18f
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: jcomponent20@3fedd009a277f50fddc608b97afbec553b67c51b
Review: not-recorded

`<ui-import>` downloads an HTML file and puts it into the page, so a big screen can be split into parts that are loaded when needed. The address goes in the `config` attribute (`url:/parts/card.html`); `target` can name another element to fill instead of the `ui-import` itself.

In code use `IMPORT(url, target, callback)`: the target is a selector or element, and the callback runs when the part is in the page. Each address is downloaded once. The same function loads scripts (`.js`) and styles (`.css`). Components and bindings inside the loaded part start working automatically.

```html public/parts/card.html
<div class="card">Hello <ui-bind path="user.name" config="text:value" class="who"></ui-bind></div>
```

```html public/parts/note.html
<div class="note">A note</div>
```

```html public/index.html
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>jComponent</title>
	<link rel="stylesheet" href="//cdn.componentator.com/spa.min@20.css" />
	<script src="//cdn.componentator.com/spa.min@20.js"></script>
</head>
<body>
	<ui-import config="url:/parts/card.html"></ui-import>
	<div id="slot"></div>

	<script>
		var done = [];
		IMPORT('/parts/note.html', '#slot', function() { done.push('slot'); });
		SET('user.name', 'Peter');
	</script>

</body>
</html>
```
