Skip to content

Asset Loader

Milkshift edited this page Jan 9, 2026 · 6 revisions

Asset loader is a system designed to handle the downloading, synchronizing, loading, and hot-reloading of external resources like scripts and themes.
By default, it is used to load client mods and renderer scripts.

Storage Location

All assets are stored locally in the assets subdirectory of the main data folder, which you can open through the settings. On startup, GoofCord scans this folder to load your themes and client modifications.

Adding and Managing Assets

There are two ways to add files to the client: using the External Assets setting for automatic updates, or manually dropping files into the folder.

External Assets

This is the recommended method to keep frequently updating assets (like Vencord) up to date.
In the "Add" button dropdown, you can either choose one of the presets, or create a custom entry.
Keys must be unique.

  • How it works: On startup, the client checks the URLs defined in your settings against the files on your disk.
  • Network Updates: If a remote file has changed (detected via ETag headers), the client downloads the new version automatically.
  • Local Synchronization: You can point an asset URL to a local file path (e.g., file:///C:/MyProjects/theme.css). The client will copy the file into the assets folder whenever the source file changes.
  • Garbage Collection: If you remove an entry from your configuration, the specific file associated with it will be automatically deleted from the assets folder to keep it clean.

Manual Management

You can simply put .css or .js files into the assets/ folder.

  • Note: Files added manually are safe. The garbage collector only removes files that were previously managed by the config and then removed.

Supported File Types

Styles (.css)

CSS files are used for themes and visual customizations.

  • Hot Reloading: The Asset Loader includes a File Watcher. If you edit a .css file inside the assets folder while the client is running, the changes will apply immediately without requiring a restart.

Scripts (.js)

JavaScript files are used for client modifications and other custom scripts.

  • Loading: Scripts are loaded into memory when the application starts.
  • Updates: Unlike CSS, modifying a .js file requires a full restart for changes to take effect.

Internals

Renderer scripts

By default, GoofCord also loads two "renderer" scripts, PreVencord and PostVencord.
These files add core functionality and allow GoofCord to communicate with Discord. They are also tightly coupled with Vencord, and so need 2 stages to properly hook it.
They are built from src/windows/main/renderer/

Script Categorization

To determine what script is what, GoofCord performs a header scan of the first 500 characters of the file content, looking for specific "Magic Strings" or markers:

  1. Pre-Vencord: prevencordmarker
  2. Vencord/Equicord: vencord
    • Note: Equicord also has vencord in its header. If multiple markers are found, asset loader will only load the last one found, as there should be only a single Vencord-based client mod.
  3. Post-Vencord: postvencordmarker
  4. Others: None

Note: If the Pre, Vencord, or Post scripts are missing during the scan, a "Critical Assets Missing" alert will be shown. GoofCord can work without the triad, but a lot of the functionality will be broken.

Asset Identification & Sanitization

When the Asset Downloader fetches files from a URL, it generates a local filename to ensure filesystem compatibility:

  1. Sanitization: Special characters in the asset name are replaced with underscores _ (e.g., My-Script! becomes My_Script_).
  2. Extension Inference: The downloader parses the URL path to find an extension.
    • If the path ends in .css, it is saved as a stylesheet.
    • If the path ends in anything else (or cannot be determined), it defaults to .js.
    • Fallback: If URL parsing fails entirely, it inspects the raw string; if that doesn't end in .css, it logs a warning and forces .js.

Clone this wiki locally