Functions
bundle_js_files
Bundle multiple JavaScript files into a single string.
Files are concatenated in the order provide…
bundle_js_files
def bundle_js_files(files: list[Path]) -> str
Bundle multiple JavaScript files into a single string.
Files are concatenated in the order provided. Each file's content is separated by a newline. Source comments can be added for debugging.
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
files |
list[Path] |
— | List of JS file paths in load order (dependencies first) |
Returns
Bundled JavaScript content as a single stringstr
—
get_theme_js_bundle_order
Return the canonical load order for Bengal default theme JS files.
This order ensures dependencies…
get_theme_js_bundle_order
def get_theme_js_bundle_order() -> list[str]
Return the canonical load order for Bengal default theme JS files.
This order ensures dependencies are loaded before dependents:
- utils.js - Core utilities (BengalUtils namespace)
- bengal-enhance.js - Enhancement registry (load second)
- core/theme.js - Theme switching (merged from theme-toggle.js + theme-init.js)
- core/search.js - Search (merged from search.js, search-modal.js, search-page.js, search-preload.js)
- core/nav-dropdown.js - Navigation dropdowns (always needed)
- core/session-path-tracker.js - Analytics (always needed)
- enhancements/mobile-nav.js - Mobile navigation
- enhancements/tabs.js - Tab component
- enhancements/toc.js - Table of contents
- enhancements/action-bar.js - Action bar (copy, etc.)
- enhancements/interactive.js - Interactive elements
- main.js - Main initialization
- enhancements/copy-link.js - Copy link functionality
- enhancements/holo.js - Holographic effects (merged from holo.js + holo-cards.js)
- enhancements/lazy-loaders.js - Lazy loading (Mermaid, D3, etc.)
Returns
List of JS filenames in load order (with paths relative to js/ directory)list[str]
—
get_theme_js_excluded
Return JS files that should NOT be bundled.
These are either:
- Third-party minified libraries (al…
get_theme_js_excluded
def get_theme_js_excluded() -> set[str]
Return JS files that should NOT be bundled.
These are either:
- Third-party minified libraries (already optimized)
- Conditionally loaded scripts (loaded via lazy-loaders.js)
- Feature-specific scripts that may not be enabled
Returns
Set of filenames to exclude from bundlingset[str]
—
discover_js_files
Discover and order JS files for bundling from a directory.
Files are ordered according to bundle_o…
discover_js_files
def discover_js_files(js_dir: Path) -> list[Path]
Discover and order JS files for bundling from a directory.
Files are ordered according to bundle_order if provided, with any remaining files appended at the end.
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
js_dir |
Path |
— | Directory containing JS files |
Returns
List of file paths in bundling orderlist[Path]
—
create_js_bundle
Create a JavaScript bundle from a theme's JS directory.
High-level function that discovers files a…
create_js_bundle
def create_js_bundle(js_dir: Path, output_path: Path | None = None) -> str
Create a JavaScript bundle from a theme's JS directory.
High-level function that discovers files and bundles them.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
js_dir |
Path |
— | Directory containing JS files |
output_path |
Path | None |
None |
Optional path to write bundle (if None, returns string only) |
Returns
Bundled JavaScript contentstr
—