Ajustes antes de produccion

This commit is contained in:
2026-10-22 00:07:21 -06:00
parent f9666c4088
commit 1be9d16c83
124 changed files with 3540 additions and 772 deletions
+47 -2
View File
@@ -16,8 +16,22 @@
return type === 'application/json' || type === 'application/ld+json' || type === 'rocketlazyloadscript';
};
const keepCheckout = (script) => {
const src = (script.getAttribute('src') || '').toLowerCase();
const attribution = script.getAttribute('data-source-attribution') || '';
const code = script.textContent || '';
if (src.includes('portable-wallets') || attribution.includes('shopify.dynamic_checkout') || code.includes('portable-wallets') || code.includes('shopify.dynamic_checkout')) return true;
// Wallet SDKs read their own script URL (PayPal needs client-id). Delaying them
// strips src and the button is removed before the shopper can click it.
return src.includes('paypal.com')
|| src.includes('paypalobjects.com')
|| src.includes('pay.google.com')
|| src.includes('payments.google.com')
|| src.includes('applepay.cdn-apple.com');
};
const holdScript = (script) => {
if (exemptScript(script)) return;
if (exemptScript(script) || keepCheckout(script)) return;
const src = script.getAttribute('src');
if (src) {
script.setAttribute('data-rocket-src', src);
@@ -29,8 +43,22 @@
script.setAttribute('type', 'rocketlazyloadscript');
};
// App-embed stylesheets (cdn.shopify.com/extensions/...) are injected in <body> and block
// rendering; their widgets sit below the fold, so load them without blocking.
const softenStyle = (link) => {
if (link.tagName !== 'LINK' || link.rel !== 'stylesheet' || link.dataset.soft) return;
const href = link.getAttribute('href') || '';
if (!(link.hasAttribute('data-app-id') || href.indexOf('/extensions/') !== -1)) return;
link.dataset.soft = '1';
const media = link.media && link.media !== 'print' ? link.media : 'all';
link.media = 'print';
const done = () => { link.media = media; };
if (link.sheet) done(); else link.addEventListener('load', done, { once: true });
};
const holdTree = (node) => {
if (!node || node.nodeType !== 1) return;
softenStyle(node);
holdScript(node);
if (node.querySelectorAll) node.querySelectorAll('script').forEach(holdScript);
};
@@ -79,6 +107,15 @@
_onTouchStart(event) {
if (event.target.tagName === 'HTML') return;
// Native controls (checkboxes, labels, inputs, plain links) and UI handled by
// non-delayed scripts work without the delayed bundle: never hold their clicks.
const target = event.target.closest ? event.target : event.target.parentElement;
if (target && target.closest && target.closest(
'input, label, select, textarea, summary, option, [contenteditable], [data-no-intercept],'
+ ' [data-filter-toggle], [data-sort-toggle], [data-filter-close], [data-sort-close],'
+ ' .collection__drawer, [data-learn] .learn__media, .product__excerpt-toggle, .edge-arrow,'
+ ' a[href]:not([href^="#"]):not([data-cart-open]):not([data-wish-open]):not([role="button"])'
)) return;
window.addEventListener('touchend', this.touchEndHandler);
window.addEventListener('mouseup', this.touchEndHandler);
window.addEventListener('touchmove', this.touchMoveHandler, { passive: true });
@@ -119,7 +156,15 @@
window.removeEventListener('touchstart', this.touchStartHandler, { passive: true });
window.removeEventListener('mousedown', this.touchStartHandler);
this.interceptedClicks.forEach((event) => {
event.target.dispatchEvent(new MouseEvent('click', { view: event.view, bubbles: true, cancelable: true }));
const target = event.target;
const control = target && target.closest ? target.closest('button, input') : null;
if (control && control.type === 'submit' && control.form && !control.disabled && typeof control.form.requestSubmit === 'function') {
control.form.requestSubmit(control);
return;
}
if (target && typeof target.dispatchEvent === 'function') {
target.dispatchEvent(new MouseEvent('click', { view: event.view, bubbles: true, cancelable: true }));
}
});
}