Godot platform web

From thedivergentai/GD-Agentic-Skills · View interactive version

Godot platform web is an AI agent skill from the GitHub repository thedivergentai/GD-Agentic-Skills. Expert blueprint for HTML5/web export on Compatibility (WebGL 2.0): JavaScriptBridge, localStorage wrapper, custom loading shells, COOP/COEP hosts, relative paths, beforeunload, visibility pause, and size optimization. WebGPU is out of scope. Keywords: web, HTML5, WebGL, Compatibility, JavaScriptBri

How to use this skill

Skill file

NEVER Do (Expert Web Rules)

Persistence & Storage

Rendering & Logic

UX & Security


Host checklist (procedure)

  1. HTTPS — Required for many browser APIs (clipboard, some storage policies, secure contexts).
  2. COOP / COEP — Serve isolation headers when enabling threads / SharedArrayBuffer (see exporting-for-web docs).
  3. Relative shell paths — Custom index.html / PCK/WASM URLs must be relative so /game/ subpaths work.
  4. beforeunload — Wire web_navigation_guard.gd when unsaved progress exists.
  5. Compatibility renderer + texture compression — Desktop browsers: S3TC/BPTC as appropriate; keep particle/draw budgets low.

Available Scripts

MANDATORY: For saves, load web_local_storage_wrapper.gd — do not paste JavaScriptBridge.eval("localStorage.setItem...") string recipes.

[web_local_storage_wrapper.gd](scripts/web_local_storage_wrapper.gd)

Quota-safe localStorage via get_interface + JSON (no eval string interpolation).

[web_javascript_bridge_callback.gd](scripts/web_javascript_bridge_callback.gd)

Two-way JS↔GD with create_callback (keep callback refs alive).

[web_responsive_canvas_adaptor.gd](scripts/web_responsive_canvas_adaptor.gd)

Canvas resize to browser viewport.

[web_browser_input_guard.gd](scripts/web_browser_input_guard.gd)

Suppress context menu / spacebar scroll defaults.

[web_resource_lazy_loader.gd](scripts/web_resource_lazy_loader.gd)

Remote PCK/resource fetch patterns.

[web_clipboard_interface.gd](scripts/web_clipboard_interface.gd)

Async clipboard via Navigator API.

[web_visibility_auto_pause.gd](scripts/web_visibility_auto_pause.gd)

Pause engine/audio on tab hide.

[web_navigation_guard.gd](scripts/web_navigation_guard.gd)

beforeunload unsaved-progress guard.

[web_external_url_opener.gd](scripts/web_external_url_opener.gd)

window.open with noopener.

[web_performance_profiler.gd](scripts/web_performance_profiler.gd)

VRAM/draw stats to JS console.

Also in `scripts/`

Expert WHY (critical)

CAUTION: Never persist via JavaScriptBridge.eval("localStorage.setItem('%s')" % data) — injection/escaping bugs. Use web_local_storage_wrapper.gd.

Deep dive (load on demand)

PWA lifecycle, JSON-RPC bridge, localStorage anti-patterns, size knobs — references/web-elite-patterns.md.

Loading shell (custom HTML)

<!-- index.html custom loading — keep asset URLs relative -->
<div id="loading-screen">
    <div class="progress-bar"><div id="progress" style="width: 0%"></div></div>
    <p id="status-text">Loading...</p>
</div>
<script>
const engine = new Engine(CONFIG);
engine.startGame({
    onProgress: function(current, total) {
        const percent = Math.floor((current / total) * 100);
        document.getElementById('progress').style.width = percent + '%';
        document.getElementById('status-text').innerText = `Loading ${percent}%`;
    }
}).then(() => {
    document.getElementById('loading-screen').style.display = 'none';
});
</script>

Feature gate

if OS.has_feature("web"):
    # Web-only: storage wrapper, visibility pause, navigation guard
    pass

Size / perf knobs

[rendering]
textures/vram_compression/import_s3tc_bptc=true
textures/vram_compression/import_etc2_astc=true

PWA update hook

func _ready() -> void:
    if OS.has_feature("web"):
        JavaScriptBridge.pwa_update_available.connect(_on_pwa_update)

func _on_pwa_update() -> void:
    if JavaScriptBridge.pwa_needs_update():
        JavaScriptBridge.pwa_update()

Reference

Progressive disclosure: open Official Documentation links only when researching a specific API;

load Related Skills when routing work to a peer domain — do not preload the whole lattice.

Official Documentation

Related Skills

Prerequisites
Complements
Downstream / consumers
Master
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.