Build · Script injection
Script Injection
Script extensions inject JavaScript and CSS directly into forum pages. Combined with the ForumSpark JavaScript SDK, they can add rich interactive features.
Package structure
{
"name": "Analytics Tracker",
"description": "Add analytics tracking to your forum.",
"js": "document.addEventListener('forumspark:init', () => { console.log('Tracking active'); });",
"css": ".analytics-badge { display: none; }",
"inject_location": "head"
}
Injection locations
| Location | Description |
|---|---|
| head | Injected inside <head>, ideal for analytics, meta tags, and early CSS |
| top_of_page | After the body opens, before the forum layout, for banners and global components |
| after_the_board | After the forum content, for footer scripts and deferred loading |
Security requirements
Packages are automatically scanned for dangerous patterns. Avoid these in your code:
| Severity | Flagged Patterns |
|---|---|
| High | eval(), Function(), document.cookie |
| Medium | fetch(), XMLHttpRequest, window.location, WebSocket, navigator.sendBeacon, importScripts |
| Low | atob(), btoa(), external CSS url() |
High-severity flags will block approval. Medium flags require justification during review.
Field reference
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Extension name (max 255 chars) |
| description | string | No | Short description (max 1000 chars) |
| js | string | No* | JavaScript code |
| css | string | No* | CSS styles |
| inject_location | string | Yes | One of: head, top_of_page, after_the_board |
* At least one of js or css must be provided.