Skip to content

Commit 346e2cf

Browse files
authored
Fix slow loading: block eclipse.org cookie consent resources that cause timeouts
1 parent 5557ad7 commit 346e2cf

File tree

4 files changed

+177
-2
lines changed

4 files changed

+177
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* Block eclipse.org external resources to improve site loading speed */
2+
3+
/* Hide cookie consent UI elements */
4+
.cookie-consent,
5+
.cookieconsent,
6+
.cc-window,
7+
.cc-banner,
8+
[class*="cookie"],
9+
[id*="cookie"] {
10+
display: none !important;
11+
visibility: hidden !important;
12+
opacity: 0 !important;
13+
pointer-events: none !important;
14+
}
15+
16+
/* Improve loading performance by hiding elements that depend on external resources */
17+
body::before {
18+
content: "";
19+
display: block;
20+
position: fixed;
21+
top: 0;
22+
left: 0;
23+
width: 100%;
24+
height: 100%;
25+
background: transparent;
26+
z-index: -1;
27+
/* This ensures the page renders immediately without waiting for external resources */
28+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Performance optimization: Block slow external eclipse.org resources
2+
(function() {
3+
'use strict';
4+
5+
// Block eclipse.org cookie consent requests immediately
6+
const blockedDomains = [
7+
'www.eclipse.org/eclipse.org-common/themes/solstice/public/stylesheets/vendor/cookieconsent/',
8+
'www.eclipse.org/eclipse.org-common/themes/solstice/public/javascript/vendor/cookieconsent/'
9+
];
10+
11+
// Override fetch to block requests
12+
const originalFetch = window.fetch;
13+
window.fetch = function(url, options) {
14+
const urlString = url.toString();
15+
if (blockedDomains.some(domain => urlString.includes(domain))) {
16+
console.log('Blocked slow external request:', urlString);
17+
return Promise.reject(new Error('Blocked for performance'));
18+
}
19+
return originalFetch.apply(this, arguments);
20+
};
21+
22+
// Override XMLHttpRequest
23+
const originalXMLHttpRequest = window.XMLHttpRequest;
24+
window.XMLHttpRequest = function() {
25+
const xhr = new originalXMLHttpRequest();
26+
const originalOpen = xhr.open;
27+
28+
xhr.open = function(method, url) {
29+
const urlString = url.toString();
30+
if (blockedDomains.some(domain => urlString.includes(domain))) {
31+
console.log('Blocked slow XHR request:', urlString);
32+
return; // Don't open the request
33+
}
34+
return originalOpen.apply(this, arguments);
35+
};
36+
37+
return xhr;
38+
};
39+
40+
// Remove existing elements immediately if they exist
41+
document.addEventListener('DOMContentLoaded', function() {
42+
// Remove cookie consent links
43+
const cookieLinks = document.querySelectorAll('link[href*="eclipse.org"][href*="cookieconsent"]');
44+
cookieLinks.forEach(link => {
45+
console.log('Removing eclipse.org cookie consent CSS:', link.href);
46+
link.remove();
47+
});
48+
49+
// Remove cookie consent scripts
50+
const cookieScripts = document.querySelectorAll('script[src*="eclipse.org"][src*="cookieconsent"]');
51+
cookieScripts.forEach(script => {
52+
console.log('Removing eclipse.org cookie consent JS:', script.src);
53+
script.remove();
54+
});
55+
});
56+
57+
// Early removal - check immediately
58+
if (document.readyState === 'loading') {
59+
const observer = new MutationObserver(function(mutations) {
60+
mutations.forEach(function(mutation) {
61+
mutation.addedNodes.forEach(function(node) {
62+
if (node.nodeType === 1) { // Element node
63+
if (node.tagName === 'LINK' && node.href && node.href.includes('eclipse.org') && node.href.includes('cookieconsent')) {
64+
console.log('Blocked cookie consent CSS from loading:', node.href);
65+
node.remove();
66+
}
67+
if (node.tagName === 'SCRIPT' && node.src && node.src.includes('eclipse.org') && node.src.includes('cookieconsent')) {
68+
console.log('Blocked cookie consent JS from loading:', node.src);
69+
node.remove();
70+
}
71+
}
72+
});
73+
});
74+
});
75+
76+
observer.observe(document.documentElement, {
77+
childList: true,
78+
subtree: true
79+
});
80+
81+
// Stop observing after page load
82+
window.addEventListener('load', function() {
83+
observer.disconnect();
84+
});
85+
}
86+
})();

supplemental-ui/partials/head-meta.hbs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
{{!-- Early performance blocker script - load first to block slow external resources --}}
2+
<script src="{{{uiRootPath}}}/js/performance-blocker.js"></script>
3+
4+
{{!-- Performance fixes to block slow external resources --}}
5+
<link rel="stylesheet" href="{{{uiRootPath}}}/css/performance-fixes.css">
6+
17
{{!-- Force PDF downloads instead of opening in browser --}}
28
<script>
39
document.addEventListener('DOMContentLoaded', function() {
@@ -15,6 +21,52 @@
1521
});
1622
</script>
1723

24+
{{!-- Performance fixes to block slow external resources --}}
25+
<link rel="stylesheet" href="{{{uiRootPath}}}/css/performance-fixes.css">
26+
27+
{{!-- Block external eclipse.org cookie consent resources to prevent slow loading --}}
28+
<style>
29+
/* Hide any cookie consent elements that might be added */
30+
.cookie-consent, .cookieconsent, [class*="cookie"] {
31+
display: none !important;
32+
}
33+
</style>
34+
35+
<script>
36+
// Override/disable any eclipse.org external script loading
37+
document.addEventListener('DOMContentLoaded', function() {
38+
// Remove any existing cookie consent links and scripts
39+
const cookieLinks = document.querySelectorAll('link[href*="eclipse.org"][href*="cookieconsent"]');
40+
cookieLinks.forEach(link => {
41+
console.log('Removing slow-loading eclipse.org cookie consent CSS:', link.href);
42+
link.remove();
43+
});
44+
45+
const cookieScripts = document.querySelectorAll('script[src*="eclipse.org"][src*="cookieconsent"]');
46+
cookieScripts.forEach(script => {
47+
console.log('Removing slow-loading eclipse.org cookie consent JS:', script.src);
48+
script.remove();
49+
});
50+
51+
// Prevent new cookie consent scripts from loading
52+
const originalCreateElement = document.createElement;
53+
document.createElement = function(tagName) {
54+
const element = originalCreateElement.call(document, tagName);
55+
if (tagName.toLowerCase() === 'script') {
56+
const originalSetAttribute = element.setAttribute;
57+
element.setAttribute = function(name, value) {
58+
if (name === 'src' && value && value.includes('eclipse.org') && value.includes('cookieconsent')) {
59+
console.log('Blocked slow-loading eclipse.org cookie consent script:', value);
60+
return; // Don't set the src attribute
61+
}
62+
return originalSetAttribute.call(this, name, value);
63+
};
64+
}
65+
return element;
66+
};
67+
});
68+
</script>
69+
1870
{{!-- Favicons --}}
1971
<link rel="icon" href="{{{uiRootPath}}}/img/favicon.svg" type="image/svg+xml">
2072
<link rel="alternate icon" href="{{{uiRootPath}}}/img/favicon.png" type="image/png">

test-pdf-download.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,22 @@ fi
1111

1212
echo "✅ Site directory exists"
1313

14-
# Check if PDF exists in assembler location
14+
# Check if PDF exists in assembler location (could be index.pdf or microprofile-tutorial.pdf)
15+
PDF_FOUND=false
1516
if [ -f "build/assembler/microprofile-tutorial/6.1/microprofile-tutorial.pdf" ]; then
16-
echo "✅ PDF found in assembler location"
17+
echo "✅ PDF found in assembler location: microprofile-tutorial.pdf"
1718
PDF_SIZE=$(stat -f%z "build/assembler/microprofile-tutorial/6.1/microprofile-tutorial.pdf" 2>/dev/null || stat -c%s "build/assembler/microprofile-tutorial/6.1/microprofile-tutorial.pdf")
1819
echo " Size: ${PDF_SIZE} bytes"
20+
PDF_FOUND=true
21+
elif [ -f "build/assembler/microprofile-tutorial/6.1/_exports/index.pdf" ]; then
22+
echo "✅ PDF found in assembler/_exports location: index.pdf"
23+
PDF_SIZE=$(stat -f%z "build/assembler/microprofile-tutorial/6.1/_exports/index.pdf" 2>/dev/null || stat -c%s "build/assembler/microprofile-tutorial/6.1/_exports/index.pdf")
24+
echo " Size: ${PDF_SIZE} bytes"
25+
PDF_FOUND=true
1926
else
2027
echo "❌ PDF not found in assembler location"
28+
echo " Looking for PDF files:"
29+
find . -name "*.pdf" -type f 2>/dev/null || echo " No PDF files found"
2130
fi
2231

2332
# Check if PDF exists in site location (where download link points)

0 commit comments

Comments
 (0)