fix: ajustes performance
This commit is contained in:
parent
552ae6fd10
commit
9ba6da6270
BIN
Qrrapido - PageSpeed Insights.v2.pdf
Normal file
BIN
Qrrapido - PageSpeed Insights.v2.pdf
Normal file
Binary file not shown.
@ -60,8 +60,22 @@
|
||||
break;
|
||||
}
|
||||
|
||||
<script>
|
||||
(adsbygoogle = window.adsbygoogle || []).push({});
|
||||
<script defer>
|
||||
// Lazy load AdSense to improve LCP
|
||||
if ('IntersectionObserver' in window) {
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
(adsbygoogle = window.adsbygoogle || []).push({});
|
||||
observer.unobserve(entry.target);
|
||||
}
|
||||
});
|
||||
});
|
||||
document.querySelectorAll('.adsbygoogle').forEach(ad => observer.observe(ad));
|
||||
} else {
|
||||
// Fallback for older browsers
|
||||
(adsbygoogle = window.adsbygoogle || []).push({});
|
||||
}
|
||||
</script>
|
||||
}
|
||||
else if (User.Identity.IsAuthenticated)
|
||||
|
||||
@ -10,6 +10,11 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - QR Rapido | Gerador QR Code Ultrarrápido</title>
|
||||
|
||||
<!-- Cache Control Headers -->
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Expires" content="0">
|
||||
|
||||
<!-- SEO Meta Tags -->
|
||||
<meta name="description" content="@Localizer["QRGenerateDescription"]">
|
||||
<meta name="keywords" content="qr rapido, gerador qr rapido, qr code rapido, codigo qr rapido, qr gratis rapido, generador qr rapido, qr ultrarapido">
|
||||
@ -40,9 +45,12 @@
|
||||
<meta name="twitter:description" content="@Localizer["QRGenerateDescription"]">
|
||||
<meta name="twitter:image" content="https://qrrapido.site/images/qrrapido-twitter-card.png">
|
||||
|
||||
<!-- Preload critical fonts -->
|
||||
<!-- Preload critical resources for performance -->
|
||||
<link rel="preload" href="/webfonts/fa-solid-900.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="preload" href="/webfonts/fa-brands-400.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="preload" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" as="style">
|
||||
<link rel="preload" href="~/css/app.min.css" as="style">
|
||||
<link rel="preload" href="~/js/app.min.js" as="script">
|
||||
|
||||
<!-- Structured Data Schema.org -->
|
||||
<script type="application/ld+json">
|
||||
@ -79,9 +87,9 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Google Analytics 4 -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script>
|
||||
<script>
|
||||
<!-- Google Analytics 4 - Optimized with defer -->
|
||||
<script defer src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script>
|
||||
<script defer>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
|
||||
@ -132,16 +140,16 @@
|
||||
|
||||
var tagAdSense = $"https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client={ViewBag.AdSenseTag}";
|
||||
var adSenseScript = $"";
|
||||
<!-- AdSense -->
|
||||
<script async src='@tagAdSense' crossorigin='anonymous'></script>
|
||||
<!-- AdSense - Optimized with defer and crossorigin -->
|
||||
<script defer src='@tagAdSense' crossorigin='anonymous'></script>
|
||||
}
|
||||
|
||||
<!-- Bootstrap 5 -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="~/css/vendor/fontawesome.min.css" asp-append-version="true" />
|
||||
<!-- Bootstrap 5 - Optimized loading -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" media="print" onload="this.media='all'">
|
||||
<link rel="stylesheet" href="~/css/vendor/fontawesome.min.css" asp-append-version="true" media="print" onload="this.media='all'" />
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link rel="stylesheet" href="~/css/app.min.css" asp-append-version="true" />
|
||||
<!-- Custom CSS - Critical above fold with cache busting -->
|
||||
<link rel="stylesheet" href="~/css/app.min.css?v=@DateTime.Now.Ticks" />
|
||||
|
||||
<!-- Translation variables for JavaScript -->
|
||||
<script>
|
||||
@ -361,42 +369,11 @@
|
||||
<!-- Bootstrap 5 JS -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<!-- Custom JS -->
|
||||
<script src="~/js/app.min.js" asp-append-version="true" defer></script>
|
||||
<!-- Custom JS with cache busting -->
|
||||
<script src="~/js/app.min.js?v=@DateTime.Now.Ticks" defer></script>
|
||||
|
||||
<!-- Fallback inline script for debug -->
|
||||
<script>
|
||||
// Fallback inline para garantir funcionamento
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Fallback inline script starting
|
||||
|
||||
const btn = document.getElementById('theme-toggle');
|
||||
if (btn) {
|
||||
// Theme toggle button found
|
||||
btn.onclick = function() {
|
||||
// Theme toggle clicked
|
||||
const html = document.documentElement;
|
||||
const current = html.getAttribute('data-theme') || 'light';
|
||||
const newTheme = current === 'light' ? 'dark' : 'light';
|
||||
html.setAttribute('data-theme', newTheme);
|
||||
console.log('Theme changed to:', newTheme);
|
||||
|
||||
const icon = document.getElementById('theme-icon');
|
||||
const text = document.getElementById('theme-text');
|
||||
if (icon) {
|
||||
icon.className = newTheme === 'dark' ? 'fas fa-moon' : 'fas fa-sun';
|
||||
}
|
||||
if (text) {
|
||||
text.textContent = newTheme === 'dark' ? 'Escuro' : 'Claro';
|
||||
}
|
||||
};
|
||||
// Theme toggle configured inline
|
||||
} else {
|
||||
console.error('❌ Botão não encontrado pelo script inline!');
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
<!-- Performance optimizations moved to external file -->
|
||||
<script src="~/js/performance-optimizations.js?v=@DateTime.Now.Ticks" defer></script>
|
||||
|
||||
@await RenderSectionAsync("Scripts", required: false)
|
||||
</body>
|
||||
|
||||
53
wwwroot/js/performance-optimizations.js
Normal file
53
wwwroot/js/performance-optimizations.js
Normal file
@ -0,0 +1,53 @@
|
||||
// QR Rapido - Performance Optimizations
|
||||
// Moved from inline scripts to improve LCP and reduce render-blocking
|
||||
|
||||
// Fallback inline para garantir funcionamento do theme toggle
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Theme toggle functionality
|
||||
const btn = document.getElementById('theme-toggle');
|
||||
if (btn) {
|
||||
btn.onclick = function() {
|
||||
const html = document.documentElement;
|
||||
const current = html.getAttribute('data-theme') || 'light';
|
||||
const newTheme = current === 'light' ? 'dark' : 'light';
|
||||
html.setAttribute('data-theme', newTheme);
|
||||
|
||||
// Save preference to localStorage
|
||||
localStorage.setItem('theme-preference', newTheme);
|
||||
|
||||
const icon = document.getElementById('theme-icon');
|
||||
const text = document.getElementById('theme-text');
|
||||
if (icon) {
|
||||
icon.className = newTheme === 'dark' ? 'fas fa-moon' : 'fas fa-sun';
|
||||
}
|
||||
if (text) {
|
||||
text.textContent = newTheme === 'dark' ? 'Escuro' : 'Claro';
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Load saved theme preference on page load
|
||||
const savedTheme = localStorage.getItem('theme-preference');
|
||||
if (savedTheme) {
|
||||
document.documentElement.setAttribute('data-theme', savedTheme);
|
||||
const icon = document.getElementById('theme-icon');
|
||||
const text = document.getElementById('theme-text');
|
||||
if (icon) {
|
||||
icon.className = savedTheme === 'dark' ? 'fas fa-moon' : 'fas fa-sun';
|
||||
}
|
||||
if (text) {
|
||||
text.textContent = savedTheme === 'dark' ? 'Escuro' : 'Claro';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Optimize CSS loading fallback
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Ensure non-critical CSS loads properly
|
||||
const printLinks = document.querySelectorAll('link[media="print"]');
|
||||
printLinks.forEach(link => {
|
||||
if (link.onload === null) {
|
||||
link.media = 'all';
|
||||
}
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user