Godot platform web

From nix-community/nur-combined · View interactive version

Godot platform web is an AI agent skill from the GitHub repository nix-community/nur-combined. Expert blueprint for web/browser platforms (HTML5 export) covering WebGL/WebGPU rendering, custom loading screens, JavaScriptBridge integration, LocalStorage saves, and size optimization. Use when exporting to web or implementing browser-specific features. Keywords web, HTML5, WebGL, WebGPU, JavaScr

How to use this skill

Skill file

Platform: Web

Browser API integration, LocalStorage persistence, and size optimization define web deployment.

NEVER Do (Expert Web Rules)

Persistence & Storage

Rendering & Logic

UX & Security


Available Scripts

MANDATORY: Read the appropriate script before implementing the corresponding pattern.

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

Expert two-way JS-to-GD communication using create_callback.

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

Robust localStorage handler with JSON serialization and quota error prevention.

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

Dynamic canvas resizing to match browser window dimensions via JS.

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

Preventing browser default behaviors (Right-click menu, Spacebar scroll).

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

Lazy loading of remote PCKs and resources using browser-fetch logic.

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

Asynchronous clipboard (Copy/Paste) integration via the Navigator API.

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

Visibility API integration to auto-pause engine and audio on tab hide.

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

Navigation guard using beforeunload to prevent closing on unsaved progress.

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

Expert URL opening using window.open with noopener security flags.

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

Browser performance tracking (VRAM, Draw calls) logged to JS console.


<!-- index.html custom loading -->
<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>

Browser Integration

# Check if running in browser
if OS.has_feature("web"):
    # Web-specific code
    JavaScriptBridge.eval("console.log('Running in browser')")

LocalStorage Save

func save_to_browser() -> void:
    if not OS.has_feature("web"):
        return
    
    var data := JSON.stringify(get_save_data())
    JavaScriptBridge.eval("localStorage.setItem('savegame', '%s')" % data)

func load_from_browser() -> Dictionary:
    if not OS.has_feature("web"):
        return {}
    
    var data_str := JavaScriptBridge.eval("localStorage.getItem('savegame')")
    if data_str:
        return JSON.parse_string(data_str)
    return {}

Size Optimization

# Minimize build size
[rendering]
textures/vram_compression/import_s3tc_bptc=false
textures/vram_compression/import_etc2_astc=true

# Exclude unnecessary exports
[export_preset]
exclude_filter="*.md,*.txt,docs/*"

Performance

Best Practices

  1. Loading Screen - Users expect feedback
  2. File Size - Keep under 50MB
  3. Mobile Web - Test on phones
  4. HTTPS - Required for many APIs

Reference

Related

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.