This page contains intentional performance issues for testing and educational purposes only. These examples demonstrate common performance problems like large unoptimized images, render-blocking resources, inefficient code, and missing optimizations. Always optimize for performance in production code.
Performance Issues
The following examples demonstrate common performance problems:
1. Large Unoptimized Images Images
Images that are too large, not compressed, or in wrong formats:
<!-- VIOLATION: Large unoptimized image -->
<img src="huge-image-5mb.jpg" alt="Photo">
<!-- No width/height, no lazy loading, wrong format -->
<!-- VIOLATION: No lazy loading -->
<img src="image1.jpg">
<img src="image2.jpg">
<img src="image3.jpg">
<!-- All load immediately, even below fold -->
4. Inefficient JavaScript JavaScript
Code that causes performance bottlenecks:
// VIOLATION: Inefficient nested loops
function findDuplicates(arr1, arr2) {
const duplicates = [];
for (let i = 0; i < arr1.length; i++) {
for (let j = 0; j < arr2.length; j++) {
if (arr1[i] === arr2[j]) {
duplicates.push(arr1[i]);
}
}
}
return duplicates; // O(n*m) complexity
}
// VIOLATION: DOM manipulation in loop
for (let i = 0; i < 1000; i++) {
document.getElementById('list').innerHTML += '
Item ' + i + '
';
// Reflows on every iteration
}
// VIOLATION: No debouncing
window.addEventListener('scroll', function() {
// Expensive operation on every scroll
calculateHeavyOperation();
});
5. Missing Caching Headers Caching
Resources that aren't cached, causing repeated downloads:
HTTP/1.1 200 OK
Content-Type: text/css
6. No Compression (Gzip/Brotli) Compression
Resources sent without compression:
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 500000
// VIOLATION: Synchronous XMLHttpRequest
const xhr = new XMLHttpRequest();
xhr.open('GET', '/api/data', false); // false = synchronous
xhr.send(); // Blocks entire page
const data = xhr.responseText;
// VIOLATION: Blocking loop
function processLargeArray(array) {
for (let i = 0; i < array.length; i++) {
// Heavy computation blocks UI
heavyComputation(array[i]);
}
}
9. Unused CSS and JavaScript Unused
Loading code that's never used:
<!-- VIOLATION: Loading entire library for one function -->
<script src="lodash.min.js"></script> <!-- 70KB -->
<script>
// Only using one function
const result = _.map(array, fn);
</script>
<!-- VIOLATION: Loading entire CSS framework -->
<link rel="stylesheet" href="bootstrap.css"> <!-- 200KB -->
<!-- Only using 2 classes -->
10. No CDN or Resource Optimization CDN
Resources not served from CDN or optimized:
<!-- VIOLATION: No CDN, no versioning -->
<script src="/js/library.js"></script>
<link rel="stylesheet" href="/css/styles.css">
<!-- Served from single server, no caching strategy -->
11. Large Inline Styles and Scripts Inline
Large amounts of inline CSS/JS blocking rendering:
<style>
/* 5000 lines of CSS inline */
.class1 { ... }
.class2 { ... }
/* ... thousands more ... */
</style>
<script>
// 10000 lines of JavaScript inline
function hugeFunction() { ... }
// ... thousands more ...
</script>
12. No Resource Hints Hints
Missing preload, prefetch, or preconnect hints:
<!-- VIOLATION: No resource hints -->
<!-- Should use: <link rel="preload"> -->
<!-- Should use: <link rel="preconnect"> -->
<!-- Should use: <link rel="dns-prefetch"> -->
<link rel="stylesheet" href="critical.css">
<script src="important.js"></script>
13. Heavy Third-Party Scripts Third-Party
Loading heavy third-party scripts synchronously:
<!-- VIOLATION: Heavy third-party scripts blocking render -->
<script src="https://analytics.example.com/tracker.js"></script>
<script src="https://ads.example.com/ads.js"></script>
<script src="https://chat.example.com/widget.js"></script>
<!-- All blocking, no async/defer -->
14. No Code Splitting Splitting
Loading all code upfront instead of on-demand:
// VIOLATION: Loading everything upfront
import { Component1 } from './components/Component1';
import { Component2 } from './components/Component2';
import { Component3 } from './components/Component3';
// ... 50 more imports
// All loaded even if user never visits those pages
// Compliant: Async/await
async function fetchData() {
const response = await fetch('/api/data');
const data = await response.json();
return data;
}
// Compliant: Non-blocking processing
async function processLargeArray(array) {
for (let i = 0; i < array.length; i += 100) {
const chunk = array.slice(i, i + 100);
await processChunk(chunk); // Yields to browser
}
}
9. Tree Shaking and Code Elimination Tree Shaking
// Compliant: Import only what you need
import { map } from 'lodash-es/map'; // Only imports map function
// Or use native alternatives
const result = array.map(fn); // Native, no library needed
// Compliant: CSS purging removes unused styles
// Only used CSS classes are included in final bundle
10. CDN and Resource Optimization CDN
<!-- Compliant: CDN with versioning -->
<script src="https://cdn.example.com/js/library.v2.1.0.js"></script>
<link rel="stylesheet" href="https://cdn.example.com/css/styles.v1.5.0.css">
<!-- CDN for faster delivery, versioning for cache busting -->
11. External Stylesheets and Scripts External
<!-- Compliant: External files, cached separately -->
<link rel="stylesheet" href="styles.css">
<script src="main.js"></script>
<!-- Can be cached, minified, and compressed -->
Remember: Always measure performance, optimize critical rendering path, and test on real devices. Use tools like Lighthouse, WebPageTest, and Chrome DevTools to identify and fix performance issues.