The Lyquix theme includes a comprehensive TypeScript library (lqx) and a customizable scripts library ($lqx). Both are compiled to browser-ready JavaScript using Bun.
The core framework library providing device detection, analytics, UI components, and utilities. Source: js/lib/lyquix/ (parent theme). Compiled to js/lyquix.js.
Do not modify - this is part of the parent theme.
The project-specific scripts library for custom JavaScript. Source: js/scripts.ts (child theme). Compiled to js/scripts.js.
This is where you add custom functionality.
Both libraries follow the same lifecycle:
- Script loads — the library file is parsed, all modules are defined (but not yet initialized)
lqxload/$lqxloadevent — dispatched immediately after the library is assigned towindow.lqx/window.$lqxinit(options)called — PHP renders an inline script in the footer that callslqx.init(options)with Theme Customizer settings (base64-encoded JSON)- Modules initialize in order — each module's
init()is called with its portion of the options object lqxready/$lqxreadyevent — dispatched after all modules have initialized
// Wait for lqx to be ready, then run custom code
lqx.ready(function() {
console.log('Screen size:', lqx.responsive.screen);
console.log('Is mobile:', lqx.detect.mobile);
});
// Or listen for the event directly
jQuery(document).on('lqxready', function() {
// lqx is fully initialized
});Modules initialize in a specific order because some depend on others:
mutation— DOM observer (needed by nearly everything)store— persistent storageutil— utility functionsdetect— device/browser detectionresponsive— breakpoint detectionanalytics— event trackinggeolocate— geolocationswipe— gesture detectionlyqbox— lightboxtheme— dark/light modemenu— navigationvideo— video helpers- Block modules:
accordion,alerts,cards,filters,gallery,map,modal,popup,tabs,slider,testimonial
Options are passed from PHP via the Theme Customizer settings (Lyquix Library Options and Scripts Options). Each module receives its own configuration key:
{
"debug": 2,
"siteURL": "https://example.com",
"responsive": { "enabled": true },
"analytics": { "enabled": true, "gaId": "G-XXXXXXX" },
"detect": { "mobile": true, "browser": true }
}Every module in the library follows the same IIFE (Immediately Invoked Function Expression) pattern:
export const myModule = (() => {
const init = (customCfg?: object) => {
// Prevent double initialization
if (vars.myModule?.init) return;
// Runtime variables
vars.myModule = { init: false };
// Default configuration
cfg.myModule = { enabled: true };
// Merge custom config
if (customCfg) cfg.myModule = jQuery.extend(true, cfg.myModule, customCfg);
// Module logic...
if (cfg.myModule.enabled) {
log('Initializing myModule');
// setup...
}
vars.myModule.init = true;
};
return { init };
})();Key conventions:
cfg.moduleName— configuration object, set once during init, merged with custom optionsvars.moduleName— runtime state, mutable during the page lifecyclevars.moduleName.init— boolean flag preventing double initialization- Read-only properties are exposed via
Object.defineProperties()with no-op setters
The Lyquix library consists of 24 TypeScript modules organized in three categories. Each module follows the same IIFE pattern with init(), cfg, and vars. See the detailed reference pages for full API documentation.
| Module | Purpose |
|---|---|
core.ts |
Global cfg/vars, logging (log, warn, error), debug levels |
util.ts |
Cookies, URL parsing, hashing, data validation, string manipulation |
detect.ts |
Browser, OS, and mobile detection — adds CSS classes to <body> |
store.ts |
Persistent client-side storage via localStorage with auto-save |
mutation.ts |
DOM mutation observer — register callbacks for added/removed/changed nodes |
responsive.ts |
Breakpoint detection, orientation, aspect ratio — sets <body> attributes |
| Module | Purpose |
|---|---|
menu.ts |
Mobile menu toggle with aria-expanded |
tabs.ts |
Tabbed interface with responsive accordion conversion |
accordion.ts |
Collapsible panels with URL hash support and multi-open option |
modal.ts |
Modal dialogs via HTML5 <dialog> with AJAX loading, cookies, display logic |
alerts.ts |
Alert notification slider (Swiper) with AJAX loading and dismissal cookies |
slider.ts |
Image/content carousel (Swiper) with pagination thumbnails |
cards.ts |
Responsive card grid (Swiper) with breakpoint-based column rules |
popup.ts |
Popup notifications with CSS-based visibility, cookies, display logic |
| Module | Purpose |
|---|---|
gallery.ts |
Image/video gallery with LyqBox lightbox integration |
lyqbox.ts |
Custom lightbox supporting images, videos, iframes, and inline HTML |
map.ts |
Google Maps with markers, info windows, and style customization |
filters.ts |
AJAX-powered post filtering with URL state management |
testimonial.ts |
Testimonial carousel (Swiper) |
theme.ts |
Light/dark mode detection from OS prefers-color-scheme |
analytics.ts |
GA4/GTM pageview and event tracking |
swipe.ts |
Touch swipe gesture detection with configurable thresholds |
geolocate.ts |
IP and GPS geolocation with region-based element visibility |
video.ts |
Video lazy loading, hover-play, and viewport-play via IntersectionObserver |
Edit js/scripts.ts in the child theme:
import { core } from '../../lyquix/js/lib/scripts/core';
// Import your custom modules
import { myModule } from './custom/scripts/my-module';
const modules: { [key: string]: any } = {
myModule
};
export const $lqx = {
init(customCfg: { [key: string]: any } = {}) {
core.init(customCfg, modules);
},
ready(callback: () => void) {
core.ready(callback);
},
get cfg() { return core.cfg; },
get vars() { return core.vars; },
};
document.dispatchEvent(new Event('$lqxload'));
(window as any).$lqx = $lqx;Create a file in js/custom/scripts/:
// js/custom/scripts/my-module.ts
export const myModule = (() => {
const cfg = {
// Default configuration
enabled: true,
selector: '.my-component'
};
const vars = {
// Runtime variables
};
function init(customCfg: object = {}) {
Object.assign(cfg, customCfg);
if (!cfg.enabled) return;
// Initialization logic
setup();
}
function setup() {
const elements = document.querySelectorAll(cfg.selector);
elements.forEach(el => {
// Component logic
});
}
return { init, cfg, vars };
})();You can pass configuration to your scripts via the Theme Customizer's Scripts Options field (JSON format):
{
"myModule": {
"enabled": true,
"selector": ".custom-selector"
}
}Or pass options directly in a template:
<script>
$lqx.ready(function() {
// Custom initialization
});
</script>Enabled by default. Can be toggled in Theme Customizer > JS. Version bundled with WordPress.
enable_jquery- Enable/disable jQueryenable_jquery_migrate- Enable/disable jQuery Migrateenable_jquery_ui- Off / Core / Core + Sortable
Always loaded from CDN. Provides device detection (mobile, tablet, desktop) and is used by the detect.ts module.
Carousel/slider library loaded from CDN. Version 11. Used by the Slider, Testimonial, and Logos blocks.
- Toggle: Theme Customizer > JS > Swiper library
- CSS:
https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css - JS:
https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js
Lightweight date manipulation library loaded from CDN. Replaces Moment.js.
- Toggle: Theme Customizer > JS > Day.js library
- JS:
https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js - Locale:
https://cdn.jsdelivr.net/npm/dayjs@1/locale/en.js
Optional frontend framework. If a js/vue.js file exists in the child theme, Vue.js 3 is loaded from CDN and the custom Vue bundle is loaded after it.
- CDN (dev):
https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.js - CDN (prod):
https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js
The analytics.ts module provides automatic event tracking for GA4/GTM:
- Tracks fine-grained user interactions
- Sends events via
gtag()ordataLayer.push() - Configurable through the Lyquix Library Options
Configure analytics in the Theme Customizer:
- GA4 Measurement ID - Your Google Analytics 4 measurement ID
- Send Pageview - Whether to send automatic pageview events
- GA via GTM - Whether GA is loaded through Google Tag Manager
The theme handles JavaScript enqueuing through php/js.php:
- Removes any JS libraries listed in "Remove JS Libraries" (customizer)
- Configures jQuery, jQuery Migrate, jQuery UI based on settings
- Enqueues MobileDetect from CDN
- Enqueues Day.js from CDN (if enabled)
- Enqueues Swiper from CDN (if enabled)
- Enqueues additional JS libraries (customizer)
- Enqueues the Lyquix library
- Enqueues Vue.js (if present)
- Enqueues the Scripts library
All scripts are loaded in the footer with true as the $in_footer parameter.
The customizer includes a toggle for Use Original JS (non-minified). On local environments (hostname ending in .test or WPCONFIG_ENVNAME=local), non-minified JS is always served automatically.
The Lyquix library supports 4 debug levels configurable in the Theme Customizer:
| Level | Output |
|---|---|
| 0 | None |
| 1 | Errors only |
| 2 | Errors + Warnings |
| 3 | Errors + Warnings + Info |
In the Theme Customizer under JS:
- Additional JS Libraries: Add URLs (one per line) for JS files to load
- Remove JS Libraries: Add handles of registered scripts to dequeue
The theme supports per-page custom JavaScript through an ACF field called custom_js. If this field has content, it is rendered as an inline <script> tag in the page footer.
After initialization, these objects are available on window:
window.lqx- The Lyquix library (core framework)window.$lqx- The Scripts library (project-specific)