Repository navigation
Closed
Description
Summary
Integrate solidos-lite to embed RDF data directly in HTML responses, eliminating the need for a second HTTP request when viewing resources in the browser.
Current Behavior
Browser → GET /resource (Accept: text/html)
Server → Returns HTML wrapper that loads mashlib from CDN
Browser → mashlib initializes, fetches /resource AGAIN (Accept: text/turtle)
Server → Returns RDF data
Browser → mashlib renders the data
Problems:
- Two HTTP round-trips required
- Cannot work offline after initial load
- Not suitable for static HTML exports
- Latency penalty for every resource view
Proposed Behavior
Browser → GET /resource (Accept: text/html)
Server → Returns HTML with:
- Embedded RDF in <script type="text/turtle"> data island
- solidos-lite shim that intercepts mashlib fetcher
Browser → solidos-lite patches fetcher.load()
Browser → mashlib reads from data island (no network request)
Browser → Renders immediately
How solidos-lite Works
solidos-lite intercepts mashlib RDF fetching by patching fetcher.load:
const originalLoad = fetcher.load.bind(fetcher)
fetcher.load = async function(uri, options = {}) {
const island = findDataIsland(uriStr)
if (island) {
// Parse locally embedded data instead of fetching
$rdf.parse(content, store, baseUri, contentType)
fetcher.requested[baseUri] = "done"
return doc
}
// Fall back to original network fetch
return originalLoad(uri, options)
}Key interception points:
fetcher.load()- main fetch functionfetcher.nowOrWhenFetched()- callback-based fetchingfetcher.getState()- reports "fetched" for data island URIs
Implementation Plan
Phase 1: Basic Integration
File: src/mashlib/index.js
Update generateDatabrowserHtml() to:
- Accept RDF content as parameter
- Embed content in
<script type="text/turtle" data-uri="...">tag - Load solidos-lite from CDN before mashlib
Phase 2: Handler Integration
File: src/handlers/resource.js
Pass RDF content to HTML generator when serving mashlib view.
Phase 3: Content Type Handling
text/turtle→ embed directlyapplication/ld+json→ embed as JSON-LDtext/n3→ embed directlyapplication/rdf+xml→ fallback to fetch
Phase 4: Large Resource Handling
const MAX_EMBED_SIZE = 100 * 1024; // 100KB threshold
if (rdfContent.length > MAX_EMBED_SIZE) {
return generateDatabrowserHtml(resourceUrl); // fetch-based
} else {
return generateDatabrowserHtml(resourceUrl, rdfContent, contentType); // embedded
}Benefits
| Benefit | Description |
|---|---|
| Performance | Single HTTP request instead of two |
| Offline Support | Save HTML file, view offline |
| Static Export | Generate static HTML sites from Solid data |
| Reduced Server Load | Half the requests for browser views |
| Better UX | Faster initial render, no loading flicker |
Considerations
Security
- Embedded content must be properly escaped to prevent XSS
- RDF in
<script>tags is generally safe (not executed as JS)
Caching
- Browser caching differs for embedded vs fetched content
- Consider ETags/Last-Modified for HTML response
Linked Resources
- solidos-lite falls back to network fetch for linked resources
- Only primary resource is embedded
Testing Plan
- Unit Tests: generateDatabrowserHtml() with embedded content
- Integration Tests: Verify single network request in devtools
- Manual Tests: Save HTML, open locally, verify offline rendering
References
Related Issues
- Issue Add did:nostr SSO and Schnorr (NIP-98) authentication #4: did:nostr authentication (completed)
- Issue Phase 2: Link did:nostr to WebID profiles (owl:sameAs) #6: WebID linking for did:nostr
LLM-friendly issue for future implementation.
Metadata
Metadata
Assignees
Labels
No labels
Activity
Phase 1: embed JSON-LD data island in mashlib HTML wrapper (#7) (#343)
melvincarvalho commentedon May 2, 2026
Closing — substantially superseded by v0.0.161.
generateDatabrowserHtml/generateModuleDatabrowserHtmlnow emit<script type="application/ld+json" id="dataisland" data-uri="…">with XSS-safe escaping and a 256 KB cap.src/handlers/resource.jspasses the JSON-LD body to the generator on the HTML path.The shim layer is a consumer concern, out of scope for JSS — the server's job is to emit the data island; clients decide how to read it.
Remaining work — translating non-JSON-LD RDF formats so they also populate the data island — is tracked separately in #344. Closing this to keep scope tight.
Translate Turtle/N3 to JSON-LD for HTML data island (#344) (#345)
PR #349: simplify — drop the upgrade auto-fallback
Default --single-user to root pod (#348) (#349)
fix(mcp): transactional put_typed_resource, federated sanitize, resou…
merge: MCP v2 review fixes (12 findings) into la3d/lws
[Agent: Claude] fix(lws): PATCH parses stored form by its media type;…
[Agent: Claude] fix(patch): N3-Patch emits full predicate IRIs on con…
Merge la3d/lws-review: post-drain review round — gate choke point, ET…