> For the complete documentation index, see [llms.txt](https://docs.realmacsoftware.com/elements-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.realmacsoftware.com/elements-docs/elements-language/component/shared-files.md).

# Shared Files

The `shared` folder lives inside the `components/` directory and provides a central location for assets and templates that are used by multiple components in your element pack. This eliminates duplication when several components need access to the same JavaScript libraries, stylesheets, or other resources.

## When to Use Shared Files

Use shared files when:

* Multiple components in your pack depend on the same JavaScript library (e.g., Alpine.js, GSAP)
* You need global CSS fixes or styles that apply across components
* Components share common images, fonts, or other media assets
* You want to inject initialization scripts or configuration once per page

## Folder Structure

```
MyElementPack.elementsdevpack/
  components/
    shared/
      assets/                 # Shared assets (JS, CSS, images, fonts, etc.)
        images/               # Subdirectories supported for organization
      templates/              # HTML/PHP templates injected into pages
        headStart/            # Injected at start of <head>
        headEnd/              # Injected at end of <head>
        bodyStart/            # Injected at start of <body>
        bodyEnd/              # Injected at end of <body>
```

## Single Inclusion Behavior

Shared files are only included **once per page**, regardless of how many components from your pack are added. This ensures libraries and styles are not duplicated and allows you to safely include dependencies that multiple components rely on.

## Learn More

* [Assets](/elements-docs/elements-language/component/shared-files/assets.md) - Store JavaScript, CSS, images, fonts, and other files
* [Templates](/elements-docs/elements-language/component/shared-files/templates.md) - Inject HTML or PHP at specific locations in the page


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.realmacsoftware.com/elements-docs/elements-language/component/shared-files.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
