-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmobile-optimizations.js
More file actions
37 lines (31 loc) · 1.31 KB
/
Copy pathmobile-optimizations.js
File metadata and controls
37 lines (31 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Mobile background optimization
function optimizeBackgroundForMobile() {
const isMobile = window.innerWidth <= 768;
const backgrounds = document.querySelectorAll('.neural-bg, .dots-bg, .wave-bg, .geometric-bg');
if (isMobile) {
// If on mobile, switch to a simpler background
switchBackground('stars');
// Disable complex backgrounds
backgrounds.forEach(bg => {
bg.style.display = 'none';
});
// Reduce neural network complexity if it's active
const neural = document.querySelector('.neural-bg');
if (neural) {
const nodes = neural.querySelectorAll('.neural-node');
const lines = neural.querySelectorAll('.neural-line');
// Keep only a few nodes and lines for better performance
for (let i = 0; i < nodes.length; i++) {
if (i > 5) nodes[i].style.display = 'none';
}
for (let i = 0; i < lines.length; i++) {
if (i > 3) lines[i].style.display = 'none';
}
}
}
}
// Call this function on page load and resize
document.addEventListener('DOMContentLoaded', function() {
optimizeBackgroundForMobile();
window.addEventListener('resize', optimizeBackgroundForMobile);
});