A Django example demonstrating Skybolt's asset caching using uv for Python dependency management.
# Install dependencies
make install
# Build assets
make build
# Run development server
make serve
# Visit http://localhost:8080- First Visit: Assets are inlined in the HTML with
sb-*attributes - Service Worker: Registers and caches the inlined assets
- Repeat Visit: Assets are served from Service Worker cache (~5ms)
- Cache Invalidation: Rebuild with
make build, refresh to see new assets cached
python-django/
├── skybolt_example/
│ ├── __init__.py
│ ├── settings.py # Django settings
│ ├── urls.py # URL routing
│ ├── views.py # Views with Skybolt integration
│ └── wsgi.py
├── static/
│ ├── css/
│ │ ├── critical.css # Above-the-fold styles
│ │ └── app.css # Main styles
│ ├── js/
│ │ └── app.js # Application JavaScript
│ └── dist/ # Built assets (generated)
├── templates/
│ └── index.html # Django template
├── manage.py # Django management script
├── pyproject.toml # Python dependencies (uv)
├── vite.config.js # Vite configuration
├── package.json # NPM dependencies
└── Makefile # Build commands
# views.py
from skybolt import Skybolt
def index(request):
sb = Skybolt("static/dist/.skybolt/render-map.json", cookies=request.COOKIES)
# Pre-render assets (Django templates don't support method calls with args)
return render(request, "index.html", {
"critical_css": sb.css("static/css/critical.css"),
"app_css": sb.css("static/css/app.css"),
"app_js": sb.script("static/js/app.js"),
"launch_script": sb.launch_script(),
})<!-- index.html -->
{{ critical_css|safe }}
{{ launch_script|safe }}
{{ app_css|safe }}
{{ app_js|safe }}- Open DevTools → Network tab
- Load the page (first visit)
- Observe: CSS/JS are inlined in the HTML
- Refresh the page
- Observe: No network requests for CSS/JS (served by Service Worker)
- Node.js 18+
- Python 3.10+
- uv (Python package manager)