# Global Scripts & Interactions

## Global Scripts & Interactions

**Files:** `src/layouts/components/widgets/GlobalScripts.astro` · **Skill level:** Beginner

Another advanced area that can confuse both beginners and experienced users is Lumio’s client-side behavior.

A lot of interaction logic is centralized in:

- `src/layouts/components/widgets/GlobalScripts.astro`

### What It Does

This file bootstraps interactive behavior for the whole site, including:

- Lucide icon hydration
- loading the scripts for dropdown fields, tabs, and accordions
- AOS animation setup
- [smooth scrolling](../../features/smooth-scroll/)
- button hover effects
- magnetic interactions
- horizontal-scroll helpers

### Why It Is Structured This Way

Lumio avoids loading all client-side features up front. `GlobalScripts.astro` sets up the fade-in animations when the page is ready, then waits for idle time before it imports heavier modules. Button hover effects wait for the first time a visitor's pointer moves over the page.

That keeps initial page load lighter than putting every script on every page immediately.

### Example Pattern Used

```js
const lenisModule = await loadDynamicModule("lenis", () => import("lenis"));
```

Then features are set up only if the page needs them, for example:

- AOS only if `[data-aos]` elements exist, and not on phones or for visitors who ask for reduced motion
- the dropdown field script only if `.hs-select` or `[data-hs-select]` exists
- the tabs script only if `[data-hs-tab]` exists
- the accordion script only if `.hs-accordion` exists
- Lucide only if `[data-lucide]` exists

### Why This Matters When Debugging

If an interaction appears “broken,” it may not be a markup problem alone. The issue could be:

- missing DOM selectors
- reduced-motion conditions
- viewport conditions
- a missing dynamic import
- a feature only initializing after user interaction

### Related Files You May Need

- `src/layouts/components/widgets/Search.astro`
- `src/layouts/components/widgets/ContactForm.astro`
- `src/layouts/components/global/header/*.astro`
- `src/plugins/`

### Rule Of Thumb

If the problem is visual structure, start in the Astro component.

If the problem is hydration, animations, dynamic imports, or interaction timing, check `GlobalScripts.astro` and the specific widget file next.