fallback() function generates a simplified SVG view for Firefox browsers, displaying the profile bio text with a polite notice about browser compatibility.
Function Signature
Type Definitions
Props
Parameters
The height of the SVG in pixels (typically 180px)
The width of the SVG in pixels (typically 420px)
Color theme for the fallback view
What It Renders
Thefallback() function renders a simplified view containing:
- Profile bio: The same introductory text used in the main view
- Browser hint: A small italic message suggesting Chrome/Safari for the full experience
- Character-by-character animation: Each letter fades in individually
- Firefox-only visibility: Hidden in all browsers except Firefox
Real Usage Example
Fromworker.ts:43-44:
Usage in GitHub README
Browser Compatibility Notes
Why a Fallback?
The main contribution graph uses advanced CSS features that may not work optimally in Firefox:<foreignObject>in SVG: While supported, rendering behavior differs- CSS container queries: Browser support varies
- CSS animations in SVG: Performance characteristics differ across browsers
content-visibility: Limited Firefox support
Firefox-Specific Rendering
The fallback uses Firefox-specific CSS to control visibility:Content
The fallback displays:Profile Bio
Browser Hint
CSS Styling
Layout
Animation Timing
The fallback uses the same animation timing as other components:SVG Attributes
Unlike other render functions,fallback() includes a viewbox attribute:
Returns
Type:string
Returns a complete SVG string with:
- Firefox-only visibility CSS
- Animated character-by-character text
- Friendly browser compatibility message
- Fixed dimensions with viewBox
- Theme-aware styling
Best Practices
- Always include a fallback: Even if your main view works in Firefox, a fallback ensures a good experience for all users
- Keep it simple: The fallback should load quickly and not rely on advanced features
- Be respectful: The browser hint is friendly, not condescending
- Test in Firefox: Verify that the fallback actually displays correctly
- Match the theme: Ensure fallback respects light/dark mode preferences
Alternative Approaches
Instead of hiding the main view in Firefox, you could:- Simplify for Firefox: Render a simplified version of the contribution graph
- Static image: Serve a pre-rendered PNG for Firefox users
- Feature detection: Use JavaScript to detect feature support
- Progressive enhancement: Start with the fallback and enhance for capable browsers