This guide provides recommendations for optimizing your website or application performance when running in Macro Browser.
Understanding Macro Browser's Architecture
Macro Browser has several key architectural features that affect performance:
Multi-Process Architecture: Like other Chromium-based browsers, Macro Browser uses separate processes for the browser core, renderer, GPU, and networking.
Privacy Features: Privacy protection mechanisms may impact performance in specific scenarios.
P2P VPN Integration: Network requests may be routed through the P2P VPN network.
Memory-First Storage: Macro Browser minimizes disk operations for privacy.
Performance Best Practices
Resource Loading Optimization
Diagram 1
Prioritize Critical Resources
Lazy Loading
Efficient JavaScript Loading
Rendering Performance
DOM Size Optimization
Macro Browser, like all Chromium-based browsers, performs better with smaller DOM trees:
Keep DOM nodes under 1,500 if possible
Maximum depth of 32 elements
No parent node with more than 60 child nodes
CSS Optimization
Animation Performance
For smooth animations, especially in privacy-focused browsers:
Compositor-Only Properties
For the best animation performance, prefer properties that only affect the compositor:
Provide fallbacks for fingerprinting-dependent features
Memory-Only Mode
No persistent storage
Use synchronization services or export functionality
Debugging Memory Issues
Migration Guide for Existing Apps
From Chrome/Firefox to Macro Browser
Area
Chrome/Firefox Pattern
Macro Browser Pattern
Storage
localStorage/cookies for all data
Use memory storage; export critical data
Analytics
Full user tracking
Privacy-respecting event counting
Performance
Network-heavy operations
Optimize for privacy layers and VPN
Web3
Simple wallet detection
Enhanced security checks and permissions
Progressive Enhancement for Macro Features
Conclusion
Optimizing for Macro Browser requires attention to privacy features and understanding the impact of its unique architecture. By following these guidelines, you can ensure your application performs well while respecting user privacy and leveraging the browser's advanced features.
Performance Checklist
[ ] Resources are properly prioritized and lazy-loaded
[ ] DOM size is minimized
[ ] CSS selectors are efficient
[ ] Animations use compositor-friendly properties
[ ] Memory is managed properly with no leaks
[ ] Network requests are optimized for privacy layers
<!-- Images -->
<img src="placeholder.jpg"
data-src="real-image.jpg"
loading="lazy"
class="lazy-image">
<!-- For browsers that don't support native lazy loading -->
<script>
if ('loading' in HTMLImageElement.prototype) {
// Convert to use native lazy loading
document.querySelectorAll('img.lazy-image').forEach(img => {
img.src = img.dataset.src;
});
} else {
// Use intersection observer polyfill
// ...
}
</script>
<!-- Defer non-critical JavaScript -->
<script src="app.js" defer></script>
<!-- Use type="module" for modern browsers (automatically deferred) -->
<script type="module" src="app.mjs"></script>
<!-- For legacy browser support -->
<script nomodule src="app.legacy.js" defer></script>
/* Avoid expensive CSS properties */
.good {
transform: translateZ(0); /* Uses GPU acceleration */
}
.avoid-when-possible {
box-shadow: 0px 0px 10px rgba(0,0,0,0.5); /* Can be expensive */
filter: blur(5px); /* Expensive for large elements */
position: fixed; /* Can trigger full repaints */
}
/* Use efficient selectors */
.efficient { color: blue; } /* Good - class selector */
.parent > .child { color: blue; } /* OK - one level of inheritance */
.parent .child .grandchild { color: blue; } /* Avoid - expensive */
// Use requestAnimationFrame for animations
function animate() {
// Update animation
element.style.transform = `translateX(${position}px)`;
// Schedule next frame
requestAnimationFrame(animate);
}
// Start animation
requestAnimationFrame(animate);
// Prefer CSS animations for simple cases
const styles = `
.animated {
transition: transform 0.3s ease-out;
will-change: transform;
}
`;
// Use appropriate data structures
// Map for key-value pairs with non-string keys
const userCache = new Map();
// Set for unique values
const uniqueVisitors = new Set();
// TypedArrays for binary data
const binaryData = new Uint8Array(1024);
class Component {
constructor() {
this.element = document.createElement('div');
this.bindEvents();
}
bindEvents() {
// Store reference to bound function for later removal
this.boundClickHandler = this.handleClick.bind(this);
this.element.addEventListener('click', this.boundClickHandler);
}
handleClick() {
// Handle click
}
destroy() {
// Remove event listeners
this.element.removeEventListener('click', this.boundClickHandler);
// Remove references
this.element = null;
this.boundClickHandler = null;
}
}
// Compress API responses
const compressionMiddleware = (req, res, next) => {
// Only compress certain content types
if (shouldCompress(req)) {
res.setHeader('Content-Encoding', 'gzip');
// Compress response
}
next();
};
// Client-side request batching
async function batchRequests(requests) {
// Combine multiple related API calls
return fetch('/batch', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ requests })
}).then(res => res.json());
}