Esc

gDom Reference

Complete listing of all properties and methods available on gDom inside Script children functions. gDom is window extended with helpers injected by app.js.


Core Properties

ftr

ftr: boolean

true if this is the user's first page load in the current 30-minute session (no __vi cookie present). Set once on startup. Use to defer heavy animations on first load.


assetLoader

assetLoader: Record<string, any>

Internal registry used by the asset worker handler to track in-flight and completed asset loads. Not intended for direct use.


triggeredEvents

triggeredEvents: Record<string, any>

Custom event registry used by animation helpers to track which scroll/visibility events have already fired. Managed by convention in widget scripts.


Asset Loading

loadPackage

loadPackage(path: string): Promise<void>

Loads a JS or CSS file from public/assets/ via the asset worker. The path is relative to /assets/. Cached in memory — safe to call multiple times for the same file.

await gDom.loadPackage("js/motion.js");
const { animate } = gDom.Motion;

loadAsset

loadAsset(name: string | string[], cb: Function): void

Lower-level asset loader used internally by loadPackage. Calls cb when the asset is injected.

addResourceToBody

addResourceToBody(url: string, opts: object, cb: Function): void

Injects a <script> or <link> element into the document and calls cb when loaded.

addWidgetToBody

addWidgetToBody(id: string, cb: Function, type: string): void

Injects a widget's assets into the document. Called internally by app.js during startup.


Dynamic Components

loadDynamicComponent

loadDynamicComponent(id: string, cb: (el: HTMLElement) => void): void

Re-injects the HTML of a Dynamic component into its placeholder element, then calls cb with the injected element.

gDom.loadDynamicComponent("my-panel", (el) => {
  console.info("panel ready", el);
});

DOM Utilities

geById

geById: typeof document.getElementById

Shorthand for document.getElementById, bound to document.

onVisible

onVisible(el: Element, cb: Function, opts?: object): void

IntersectionObserver wrapper. Calls cb when el enters the viewport.

debounce

debounce(fn: Function, delay: number): Function

Returns a debounced version of fn that fires at most once per delay milliseconds.

stall

stall(ms: number): Promise<void>

Returns a Promise that resolves after ms milliseconds.


setCookie

setCookie(name: string, value: string, days: number): void

Sets a browser cookie with the given name, value, and expiry in days.

getCookie

getCookie(name: string): string | null

Returns the value of a browser cookie, or null if not found.


Available After loadPackage

These properties become available on gDom after calling loadPackage with the corresponding file:

PropertyAvailable after
gDom.MotionloadPackage("js/motion.js")
gDom.LenisloadPackage("js/lenis.min.js")

The library must assign itself to window for it to appear on gDom.