This page contains intentional browser compatibility issues for testing and educational purposes only. These examples demonstrate code that may not work in certain browsers, missing polyfills, and browser-specific bugs. Always test across multiple browsers and use feature detection before using modern features.
Browser Compatibility Issues
The following examples demonstrate common browser compatibility problems:
1. Using Modern JavaScript Without Transpilation JavaScript
Modern JavaScript features that don't work in older browsers:
// VIOLATION: Modern JavaScript without transpilation
const arrowFunction = () => { ... }; // IE11 doesn't support
const spread = [...array1, ...array2]; // IE11 doesn't support
const { name, age } = user; // Destructuring - IE11 doesn't support
class MyClass { ... } // Classes - IE11 doesn't support
const promise = fetch('/api'); // Fetch API - IE11 doesn't support
const asyncFunc = async () => { ... }; // Async/await - IE11 doesn't support
2. CSS Grid Without Fallback CSS
CSS Grid not supported in older browsers:
/* VIOLATION: CSS Grid - no fallback */
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
/* IE11 and older don't support CSS Grid */
Item 1
Item 2
Item 3
May not display correctly in IE11 or older browsers
3. CSS Flexbox Without Vendor Prefixes CSS
Flexbox may need vendor prefixes for older browsers:
/* VIOLATION: No vendor prefixes */
.container {
display: flex;
justify-content: flex-start;
align-items: center;
}
/* Older browsers may need -webkit-, -ms- prefixes */
Using properties that only work in specific browsers:
/* VIOLATION: Browser-specific without fallback */
.element {
-webkit-backdrop-filter: blur(10px); /* Only WebKit browsers */
backdrop-filter: blur(10px); /* Modern browsers */
/* No fallback for other browsers */
}
7. Missing Feature Detection Detection
Using features without checking if they're supported:
// VIOLATION: No feature detection
function useFeature() {
// Assumes feature exists
if (window.IntersectionObserver) {
// Uses IntersectionObserver
} else {
// No fallback, just fails silently
}
}
// VIOLATION: Direct usage
document.querySelector('.element').classList.add('active');
// querySelector may not exist in very old browsers
8. ES6+ Array Methods JavaScript
Modern array methods not supported in older browsers:
// VIOLATION: ES6+ array methods
const doubled = array.map(x => x * 2); // IE11 supports
const filtered = array.filter(x => x > 5); // IE11 supports
const found = array.find(x => x.id === 5); // IE11 doesn't support
const includes = array.includes(5); // IE11 doesn't support
const flat = array.flat(); // IE11 doesn't support
const flatMap = array.flatMap(x => [x, x * 2]); // IE11 doesn't support
9. Template Literals JavaScript
Template literals not supported in IE11:
// VIOLATION: Template literals - IE11 doesn't support
const name = 'John';
const message = `Hello, ${name}!`; // IE11 doesn't support
const multiLine = `Line 1
Line 2`; // IE11 doesn't support
10. CSS Container Queries CSS
Container queries not supported in many browsers:
/* VIOLATION: Container queries - limited support */
.container {
container-type: inline-size;
}
@container (min-width: 500px) {
.item {
background: blue;
}
}
/* Only supported in very recent browsers */
11. CSS :has() Selector CSS
:has() selector has limited browser support:
/* VIOLATION: :has() selector - limited support */
.parent:has(.child) {
background: blue;
}
/* Not supported in Firefox until recently, not in older browsers */
12. Web APIs Without Checks APIs
Using Web APIs that may not be available:
// VIOLATION: No availability checks
localStorage.setItem('key', 'value'); // May not exist in private browsing
sessionStorage.getItem('key'); // May not exist
navigator.geolocation.getCurrentPosition(...); // May not be available
window.Notification.requestPermission(); // May not be supported
13. CSS Logical Properties CSS
Logical properties have limited support:
/* VIOLATION: Logical properties - limited support */
.element {
margin-inline-start: 20px; /* Instead of margin-left */
padding-block-end: 10px; /* Instead of padding-bottom */
border-inline: 1px solid; /* Instead of border-left/right */
}
/* Not supported in older browsers */
14. JavaScript Optional Chaining JavaScript
Optional chaining not supported in older browsers:
// VIOLATION: Optional chaining - IE11 doesn't support
const name = user?.profile?.name; // IE11 doesn't support
const value = data?.items?.[0]?.value; // IE11 doesn't support
const result = func?.(); // IE11 doesn't support
15. CSS Aspect Ratio CSS
Aspect ratio property has limited support:
/* VIOLATION: aspect-ratio - limited support */
.image {
aspect-ratio: 16 / 9;
width: 100%;
}
/* Not supported in older browsers */
Browser Compatibility Solutions
The following examples demonstrate proper cross-browser compatibility practices:
1. Transpiled JavaScript Transpiled
// Compliant: Use Babel to transpile modern JS
// Source (modern):
const arrowFunction = () => { ... };
// Transpiled (compatible):
var arrowFunction = function() { ... };
// Or use feature detection
if (typeof fetch !== 'undefined') {
fetch('/api');
} else {
// Fallback for older browsers
var xhr = new XMLHttpRequest();
xhr.open('GET', '/api');
xhr.send();
}
// Compliant: Feature detection
function useFeature() {
if ('IntersectionObserver' in window) {
const observer = new IntersectionObserver(callback);
observer.observe(element);
} else {
// Fallback for browsers without IntersectionObserver
// Use scroll event or other method
window.addEventListener('scroll', fallbackHandler);
}
}
// Compliant: Check before using
if (document.querySelector) {
const element = document.querySelector('.element');
if (element) {
element.classList.add('active');
}
} else {
// Fallback for very old browsers
const element = document.getElementsByClassName('element')[0];
if (element) {
element.className += ' active';
}
}
✓ Feature detection working correctly
8. Polyfills for Array Methods Polyfills
// Compliant: Use polyfills or feature detection
if (!Array.prototype.find) {
Array.prototype.find = function(predicate) {
for (var i = 0; i < this.length; i++) {
if (predicate(this[i], i, this)) {
return this[i];
}
}
return undefined;
};
}
// Or use alternative approach
const found = array.filter(x => x.id === 5)[0]; // Works in IE11
9. String Concatenation for IE11 Compatible
// Compliant: Compatible string concatenation
const name = 'John';
const message = 'Hello, ' + name + '!'; // Works in all browsers
// Or transpile template literals
const multiLine = 'Line 1\n' +
'Line 2'; // Works in all browsers
BrowserStack or Sauce Labs for cross-browser testing
Can I Use (caniuse.com) for feature support
Babel for JavaScript transpilation
Autoprefixer for CSS prefixes
Polyfill.io for API polyfills
About This Page
This page is designed for:
Testing browser compatibility analysis tools
Training developers on cross-browser compatibility
Understanding browser support differences
Learning about polyfills and feature detection
Remember: Always test your code in multiple browsers, use feature detection, provide fallbacks, and consider your target audience's browser usage. Use tools like Babel, Autoprefixer, and polyfills to ensure compatibility.