Title: Data Island Integration: Embed RDF in HTML with solidos-lite · Issue #7 · JavaScriptSolidServer/JavaScriptSolidServer · GitHub
Open Graph Title: Data Island Integration: Embed RDF in HTML with solidos-lite · Issue #7 · JavaScriptSolidServer/JavaScriptSolidServer
X Title: Data Island Integration: Embed RDF in HTML with solidos-lite · Issue #7 · JavaScriptSolidServer/JavaScriptSolidServer
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 → Retu...
Open Graph 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 /re...
X 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 /re...
Opengraph URL: https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/issues/7
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Data Island Integration: Embed RDF in HTML with solidos-lite","articleBody":"## Summary\n\nIntegrate [solidos-lite](https://github.com/solid-lite/solidos-lite) to embed RDF data directly in HTML responses, eliminating the need for a second HTTP request when viewing resources in the browser.\n\n## Current Behavior\n\n```\nBrowser → GET /resource (Accept: text/html)\nServer → Returns HTML wrapper that loads mashlib from CDN\nBrowser → mashlib initializes, fetches /resource AGAIN (Accept: text/turtle)\nServer → Returns RDF data\nBrowser → mashlib renders the data\n```\n\n**Problems:**\n- Two HTTP round-trips required\n- Cannot work offline after initial load\n- Not suitable for static HTML exports\n- Latency penalty for every resource view\n\n## Proposed Behavior\n\n```\nBrowser → GET /resource (Accept: text/html)\nServer → Returns HTML with:\n - Embedded RDF in \u003cscript type=\"text/turtle\"> data island\n - solidos-lite shim that intercepts mashlib fetcher\nBrowser → solidos-lite patches fetcher.load()\nBrowser → mashlib reads from data island (no network request)\nBrowser → Renders immediately\n```\n\n## How solidos-lite Works\n\nsolidos-lite intercepts mashlib RDF fetching by patching `fetcher.load`:\n\n```javascript\nconst originalLoad = fetcher.load.bind(fetcher)\n\nfetcher.load = async function(uri, options = {}) {\n const island = findDataIsland(uriStr)\n \n if (island) {\n // Parse locally embedded data instead of fetching\n $rdf.parse(content, store, baseUri, contentType)\n fetcher.requested[baseUri] = \"done\"\n return doc\n }\n \n // Fall back to original network fetch\n return originalLoad(uri, options)\n}\n```\n\nKey interception points:\n1. `fetcher.load()` - main fetch function\n2. `fetcher.nowOrWhenFetched()` - callback-based fetching \n3. `fetcher.getState()` - reports \"fetched\" for data island URIs\n\n## Implementation Plan\n\n### Phase 1: Basic Integration\n\n**File: `src/mashlib/index.js`**\n\nUpdate `generateDatabrowserHtml()` to:\n1. Accept RDF content as parameter\n2. Embed content in `\u003cscript type=\"text/turtle\" data-uri=\"...\">` tag\n3. Load solidos-lite from CDN before mashlib\n\n### Phase 2: Handler Integration\n\n**File: `src/handlers/resource.js`**\n\nPass RDF content to HTML generator when serving mashlib view.\n\n### Phase 3: Content Type Handling\n\n- `text/turtle` → embed directly\n- `application/ld+json` → embed as JSON-LD\n- `text/n3` → embed directly\n- `application/rdf+xml` → fallback to fetch\n\n### Phase 4: Large Resource Handling\n\n```javascript\nconst MAX_EMBED_SIZE = 100 * 1024; // 100KB threshold\n\nif (rdfContent.length > MAX_EMBED_SIZE) {\n return generateDatabrowserHtml(resourceUrl); // fetch-based\n} else {\n return generateDatabrowserHtml(resourceUrl, rdfContent, contentType); // embedded\n}\n```\n\n## Benefits\n\n| Benefit | Description |\n|---------|-------------|\n| **Performance** | Single HTTP request instead of two |\n| **Offline Support** | Save HTML file, view offline |\n| **Static Export** | Generate static HTML sites from Solid data |\n| **Reduced Server Load** | Half the requests for browser views |\n| **Better UX** | Faster initial render, no loading flicker |\n\n## Considerations\n\n### Security\n- Embedded content must be properly escaped to prevent XSS\n- RDF in `\u003cscript>` tags is generally safe (not executed as JS)\n\n### Caching\n- Browser caching differs for embedded vs fetched content\n- Consider ETags/Last-Modified for HTML response\n\n### Linked Resources\n- solidos-lite falls back to network fetch for linked resources\n- Only primary resource is embedded\n\n## Testing Plan\n\n1. **Unit Tests**: generateDatabrowserHtml() with embedded content\n2. **Integration Tests**: Verify single network request in devtools\n3. **Manual Tests**: Save HTML, open locally, verify offline rendering\n\n## References\n\n- [solidos-lite repository](https://github.com/solid-lite/solidos-lite)\n- [solidos-lite npm](https://www.npmjs.com/package/solidos-lite)\n- [mashlib repository](https://github.com/solid/mashlib)\n\n## Related Issues\n\n- Issue #4: did:nostr authentication (completed)\n- Issue #6: WebID linking for did:nostr\n\n---\n\n*LLM-friendly issue for future implementation.*","author":{"url":"https://github.com/melvincarvalho","@type":"Person","name":"melvincarvalho"},"datePublished":"2025-12-28T15:53:04Z","url":"https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/issues/7"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3f03f2d6-0f6f-0941-5a02-9d85ec71cf6a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DF26:13FB37:F538C:1448BD:6B039648 |
| html-safe-nonce | 3ce3656c61e03622c35376af4a6dbb85bc4d3afee55574c998f79e2514f6ac0c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjI2OjEzRkIzNzpGNTM4QzoxNDQ4QkQ6NkIwMzk2NDgiLCJ2aXNpdG9yX2lkIjoiODg2NTcyNzY1NTE5MDk1OTY4OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5e89d68e9f211670f1499f9bbc66c2dd3ce9e6f85f60e579f80b9a904d390e16 |
| hovercard-subject-tag | issue:3765778511 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/JavaScriptSolidServer/JavaScriptSolidServer/7/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3939d4be5f87ad181aff2b9a37cca72f5fb1abd5530e5887acb1bb7835d942fd/JavaScriptSolidServer/JavaScriptSolidServer/issues/7 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3939d4be5f87ad181aff2b9a37cca72f5fb1abd5530e5887acb1bb7835d942fd/JavaScriptSolidServer/JavaScriptSolidServer/issues/7 |
| og:image:alt | 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 /re... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | melvincarvalho |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/JavaScriptSolidServer/JavaScriptSolidServer git https://github.com/JavaScriptSolidServer/JavaScriptSolidServer.git |
| octolytics-dimension-user_id | 205442424 |
| octolytics-dimension-user_login | JavaScriptSolidServer |
| octolytics-dimension-repository_id | 958025407 |
| octolytics-dimension-repository_nwo | JavaScriptSolidServer/JavaScriptSolidServer |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 958025407 |
| octolytics-dimension-repository_network_root_nwo | JavaScriptSolidServer/JavaScriptSolidServer |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width