Kindle browser constraints
Kindle devices run an older WebKit-based browser with severely limited features compared to modern browsers.JavaScript version
Not available
- Arrow functions:
() => {} - Template literals:
`Hello ${name}` - Destructuring:
const {x, y} = obj - Spread operator:
...array letandconstdeclarations- Classes:
class MyClass {} - Promises and async/await
- Array methods like
.find(),.includes(),.from() Map,Set,Symbol,WeakMap
Must use instead
varfor all variable declarationsfunctionkeyword for functions- String concatenation:
'Hello ' + name Array.prototype.indexOf()instead of.includes()- Callback-based patterns instead of promises
- XMLHttpRequest instead of fetch API
ES5 patterns in KAnki source
Here are examples from the actual codebase:Polyfills included
KAnki includespolyfill.min.js to provide some modern JavaScript features as ES5-compatible implementations. However, the core codebase avoids relying on these when possible.
CSS limitations
The Kindle browser supports only basic CSS2 with minimal CSS3 features.Not available
- No Flexbox:
display: flexis not supported - No CSS Grid:
display: gridis not supported - No CSS variables:
var(--color-primary)doesn’t work - Limited transforms: Most
transformproperties fail - No animations:
@keyframesandanimationare unreliable - No media queries:
@mediahas very limited support - No pseudo-elements:
:beforeand:afterwork inconsistently
What works
Layout strategy
From the KAnki source, the app uses:- Table-based layouts for complex arrangements:
- Fixed heights to prevent layout shifts on e-ink displays:
- Absolute positioning for overlays:
Font loading
Custom fonts must use@font-face with TTF format:
KAnki waits 1000ms after page load to ensure fonts are loaded before displaying cards. This prevents rendering issues with non-Latin scripts.
E-ink display optimization
E-ink screens refresh slowly and can show ghosting. KAnki implements several techniques to minimize visual issues:Fixed element heights
Visibility instead of display
Grayscale enforcement
Screen size variations
Different Kindle models have vastly different resolutions:- Basic Kindle: 600×800 pixels
- Paperwhite: 1072×1448 pixels (higher DPI)
- Oasis: 1264×1680 pixels
- Scribe: 1860×2480 pixels
Responsive scaling
KAnki detects screen size and applies device-specific scaling:Size-specific CSS classes
The app adds classes to enable device-specific styling:Storage limitations
localStorage only
KAnki useslocalStorage exclusively:
Storage location
Data is stored at:localStorage has a size limit of approximately 5-10MB on Kindle devices. For large decks (1000+ cards with extensive history), this can become a constraint.
Performance considerations
Debouncing viewport changes
Preventing accidental inputs
DOM updates
Reuse existing elements instead of recreating:Development workflow
When customizing KAnki:- Test on actual hardware: Kindle’s browser behavior differs significantly from desktop browsers
- Use ES5 syntax exclusively: Run code through an ES5 transpiler if needed
- Avoid modern CSS: Stick to table layouts and absolute positioning
- Minimize DOM manipulation: Batch updates and reuse elements
- Test all Kindle models: Screen sizes vary dramatically
Can I use a transpiler?
Can I use a transpiler?
While you could use Babel to transpile modern JavaScript to ES5, the KAnki source code is deliberately written in ES5 to avoid build steps and keep development simple. If you add transpilation, test thoroughly on actual Kindle hardware as some polyfills may not work correctly.
Why not use progressive enhancement?
Why not use progressive enhancement?
Progressive enhancement would add complexity without benefit. Since the target platform (Kindle) is well-defined and unchanging, optimizing specifically for Kindle’s capabilities produces the most reliable results.