> For the complete documentation index, see [llms.txt](https://docs.wem.io/platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wem.io/platform/tutorials/building-widgets/basics/8-resources.md).

# 8. Resources

{% hint style="info" %}
A CSP-compliant version is available for download on the [Examples](/platform/tutorials/building-widgets/examples.md) page.
{% endhint %}

When we refer to a resource, we mean any type of file that will be embedded with the widget. This can include images, sounds, PDF documents, JavaScript, CSS, XML files, and more.

In this chapter, we are going to create a CSS file, a JavaScript file, embed a video, and add them as resources to our widget. Let's get started!

#### Creating the CSS File

1. Copy the following CSS content:

```css
.wem-academy-tickle {
	animation: shake infinite 0.4s;
}

@keyframes shake {
	0% { transform: translate(0, 0); }
	10% { transform: translate(4px, -4px); }
	20% { transform: translate(-2px, 4px); }
	30% { transform: translate(1px, 2px); }
	40% { transform: translate(-4px, -4px); }
	50% { transform: translate(0, -1px); }
	60% { transform: translate(4px, -4px); }
	70% { transform: translate(-4px, 2px); }
	80% { transform: translate(-1px, -4px); }
	90% { transform: translate(4px, -4px); }
}
```

2. Paste it into your favorite text editor.
3. Save the file as "tickle.css" on your computer.

#### Creating the JavaScript File

1. Copy the following JavaScript content:

```javascript
function startTickle(videoElement) {
	videoElement.classList.add("wem-academy-tickle");
	videoElement.play();
}

function pauseTickle(videoElement) {
	videoElement.classList.remove("wem-academy-tickle");
	videoElement.pause();
}
```

2. Paste it into your text editor.
3. Save the file as "tickle.js."

#### Downloading the Video

1. Download the video "tickle.mp4" that we are going to embed here.

{% file src="/files/geHSnOD8A5EAHFen4nNY" %}

Now that we have all the resources locally on our computer, let's create the widget.

#### Creating the Widget

1. Create a new widget named "Tickle."
2. Select the Resources tab.
3. Click on "New resource."
4. Name it "TickleCss."

A resource has been created, but without any file attached to it. In this case, we need to upload our newly created "tickle.css" file.

1. Select the "TickleCss" resource if it is not already selected.
2. Click the "Browse" button in the details panel on the right.
3. Select the newly created "tickle.css" file on your computer.
4. Click "OK."

The last three steps may vary slightly depending on the browser you are using.

The file should now be uploaded, and under the "File" column in the resources overview, the cell should display "tickle.css."

Now, repeat the process to create two more resources for "tickle.js" and "tickle.mp4," naming them "TickleJs" and "TickleVideo," respectively.

#### Adding the WEMscript

Almost there!

1. Copy the HTML code below and paste it as a Script in the Widget Editor:

```html
<? scriptreference "wem-academy-tickle" FileUrl(@TickleJs) ?>
<link rel="stylesheet" href="<?attr FileUrl(@TickleCss) ?>">
<video class="tickle" loop src="<?attr FileUrl(@TickleVideo) ?>" onmousemove="startTickle(this)" onmouseout="pauseTickle(this)"></video>
```

We introduce a new statement here called `scriptreference`, which requires two arguments. The first one should be a unique key (more on that in later chapters), and the second one is the URL of the resource. We also introduce the `FileUrl` function to retrieve the file URLs of all the resources.

**Important Note:** Every CSS and JavaScript file that you include in the widget will be globally interpreted in the browser. This means that if you are not careful, you could create CSS collisions or, even worse, overwrite JavaScript variables, functions, and classes! We will discuss this in more depth in later chapters.

For now, preview this widget, and hover over the video! :)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wem.io/platform/tutorials/building-widgets/basics/8-resources.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
