### Rocket Preload Links Initialization
Source: https://www.assuranceendirect.com/le-jet-ski-un-loisir-a-haut-risque.html
This snippet initializes the Rocket Preload Links functionality. It checks for the existence of `RocketPreloadLinksConfig` and, if available, instantiates a `RocketBrowserCompatibilityChecker` and a `RocketPreloadLinks` object, then calls its `init()` method to start the preloading process.
```JavaScript
key:"run",value:function(){ "undefined"!=typeof RocketPreloadLinksConfig&&new n(new RocketBrowserCompatibilityChecker({capture:!0,passive:!0}),RocketPreloadLinksConfig).init()}}]),n}();t.run(); }());
```
--------------------------------
### Implement Google Tag Manager (GTM)
Source: https://www.assuranceendirect.com/garantie-quels-evenements-garantis-en-cas-catastrophes-naturelles.html
This JavaScript snippet initializes Google Tag Manager, pushing the GTM start event to the dataLayer and asynchronously loading the GTM container script. This setup allows for flexible management of various tracking tags and marketing pixels.
```JavaScript
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-53X9WXCF');
```
--------------------------------
### Preload and Preconnect Resource Hints (N method)
Source: https://www.assuranceendirect.com/assurance-scooter-50cc-mbk-booster-13-naked.html
This method dynamically creates and appends `` elements to the document head for resource hints like `preload` and `preconnect`. It optimizes resource loading by informing the browser about critical resources needed soon, setting `fetchPriority` and handling `crossOrigin` attributes.
```javascript
N(t,e){
this.trash=this.trash||[];
let i=!0;
var o=document.createDocumentFragment();
t.forEach((t=>{
const s=t.getAttribute&&t.getAttribute("data-rocket-src")||t.src;
if(s&&!s.startsWith("data:")){
const n=document.createElement("link");
n.href=s,n.rel=e,
"preconnect"!==e&&(n.as="script",n.fetchPriority=i?"high":"low"),
t.getAttribute&&"module"===t.getAttribute("data-rocket-type")&&(n.crossOrigin=!0),
t.crossOrigin&&(n.crossOrigin=t.crossOrigin),
t.integrity&&(n.integrity=t.integrity),
t.nonce&&(n.nonce=t.nonce),
o.appendChild(n),
this.trash.push(n),
i=!1
}
})),
document.head.appendChild(o)
}
```
--------------------------------
### RocketLazyLoadScripts Class Initialization
Source: https://www.assuranceendirect.com/garantie-catastrophes-naturelles.html
This snippet defines the entry point for the `RocketLazyLoadScripts` class. The static `run` method instantiates the class and calls its `t()` method (which is not fully detailed in this extract but implies the main setup and execution logic for the lazy loading system). This ensures the script initializes and starts its operations upon execution.
```javascript
static run(){(new RocketLazyLoadScripts).t()}RocketLazyLoadScripts.run()})();
```
--------------------------------
### JavaScript Link Preloading Class
Source: https://www.assuranceendirect.com/stabilite-d-un-scooter-125.html
This class, `RocketPreloadLinks`, implements the core logic for preloading links to improve navigation performance. It utilizes the `RocketBrowserCompatibilityChecker` and `RocketPreloadLinksConfig` to intelligently decide when and which links to prefetch. It listens for mouseover, mousedown, and touchstart events, applies configured delays and throttling, and dynamically adds `` elements to the document head.
```javascript
(function() {
"use strict";
var r = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
return typeof e;
} : function(e) {
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
},
e = function() {
function i(e, t) {
for (var n = 0; n < t.length; n++) {
var i = t[n];
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i);
}
}
return function(e, t, n) {
return t && i(e.prototype, t), n && i(e, n), e;
};
}();
function i(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
}
var t = function() {
function n(e, t) {
i(this, n), this.browser = e, this.config = t, this.options = this.browser.options, this.prefetched = new Set, this.eventTime = null, this.threshold = 1111, this.numOnHover = 0;
}
return e(n, [{
key: "init",
value: function() {
!this.browser.supportsLinkPrefetch() || this.browser.isDataSaverModeOn() || this.browser.isSlowConnection() || (this.regex = {
excludeUris: RegExp(this.config.excludeUris, "i"),
images: RegExp(".(" + this.config.imageExt + ")$", "i"),
fileExt: RegExp(".(" + this.config.fileExt + ")$", "i")
}, this._initListeners(this));
}
}, {
key: "_initListeners",
value: function(e) {
-1 < this.config.onHoverDelay && document.addEventListener("mouseover", e.listener.bind(e), e.listenerOptions), document.addEventListener("mousedown", e.listener.bind(e), e.listenerOptions), document.addEventListener("touchstart", e.listener.bind(e), e.listenerOptions);
}
}, {
key: "listener",
value: function(e) {
var t = e.target.closest("a"),
n = this._prepareUrl(t);
if (null !== n) switch (e.type) {
case "mousedown":
case "touchstart":
this._addPrefetchLink(n);
break;
case "mouseover":
this._earlyPrefetch(t, n, "mouseout");
}
}
}, {
key: "_earlyPrefetch",
value: function(t, e, n) {
var i = this,
r = setTimeout(function() {
if (r = null, 0 === i.numOnHover) setTimeout(function() {
return i.numOnHover = 0;
}, 1e3); else if (i.numOnHover > i.config.rateThrottle) return;
i.numOnHover++, i._addPrefetchLink(e);
}, this.config.onHoverDelay);
t.addEventListener(n, function e() {
t.removeEventListener(n, e, {
passive: !0
}), null !== r && (clearTimeout(r), r = null);
}, {
passive: !0
});
}
}, {
key: "_addPrefetchLink",
value: function(i) {
return this.prefetched.add(i.href), new Promise(function(e, t) {
var n = document.createElement("link");
n.rel = "prefetch", n.href = i.href, n.onload = e, n.onerror = t, document.head.appendChild(n);
}).catch(function() {});
}
}, {
key: "_prepareUrl",
value: function(e) {
if (null === e || "object" !== (void 0 === e ? "undefined" : r(e)) || !1 in e || -1 === ["http:", "https:"].indexOf(e.protocol)) return null;
var t = e.href.substring(0, this.config.siteUrl.length),
n = this._getPathname(e.href, t),
i = {
original: e.href,
protocol: e.protocol,
origin: t,
pathname: n,
href: t + n
};
return this._isLinkOk(i) ? i : null;
}
}, {
key: "_getPathname",
value: function(e, t) {
var n = t ? e.substring(this.config.siteUrl.length) : e;
return n.startsWith("/") || (n = "/" + n), this._shouldAddTrailingSlash(n) ? n + "/" : n;
}
}, {
key: "_shouldAddTrailingSlash",
value: function(e) {
return this.config.usesTrailingSlash && !e.endsWith("/") && !this.regex.fileExt.test(e);
}
}, {
key: "_isLinkOk",
value: function(e) {
return null !== e && "object" === (void 0 === e ? "undefined" : r(e)) && (!this.prefetched.has(e.href) && e.origin === this.config.siteUrl && -1 === e);
}
}]
), t;
}();
})();
```
--------------------------------
### Initialize Google Tag Manager
Source: https://www.assuranceendirect.com/le-permis-cotier-pour-jet-ski.html
This JavaScript snippet initializes Google Tag Manager (GTM) on a web page. It pushes the GTM start event and current timestamp to the data layer, then asynchronously loads the GTM script from Google's servers using a specific container ID. This is a standard setup for web analytics and tag management.
```JavaScript
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-53X9WXCF');
```
--------------------------------
### RocketPreload Class Initialization and Listener Setup
Source: https://www.assuranceendirect.com/definition-vandalisme.html
This snippet shows the constructor and initialization logic for the `RocketPreload` class. It sets up properties like `browser`, `config`, `prefetched` set, and event timing. The `init` method checks for browser support and connection status before initializing regular expressions for URL filtering and setting up event listeners for `mouseover`, `mousedown`, and `touchstart`.
```javascript
var t=function(){
function n(e,t){
i(this,n),
this.browser=e,
this.config=t,
this.options=this.browser.options,
this.prefetched=new Set,
this.eventTime=null,
this.threshold=1111,
this.numOnHover=0
}
return e(n,[
{key:"init",value:function(){
!this.browser.supportsLinkPrefetch()||
this.browser.isDataSaverModeOn()||
this.browser.isSlowConnection()||(
this.regex={
excludeUris:RegExp(this.config.excludeUris,"i"),
images:RegExp(".("+this.config.imageExt+")$","i"),
fileExt:RegExp(".("+this.config.fileExt+")$","i")
},
this._initListeners(this)
)
}},
{key:"_initListeners",value:function(e){
-1` tags, and `_prepareUrl`, `_getPathname`, `_shouldAddTrailingSlash`, `_isLinkOk` for URL validation and normalization. The `run` method orchestrates the initialization of the preloading system.
```JavaScript
(function() {
"use strict";
var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},
e=function(){
function i(e,t){
for(var n=0;ni.config.rateThrottle)
return;
i.numOnHover++,
i._addPrefetchLink(e)
},this.config.onHoverDelay);
t.addEventListener(n,function e(){
t.removeEventListener(n,e,{passive:!0}),
null!==r&&(clearTimeout(r),r=null)
},{passive:!0})
}
},{
key:"_addPrefetchLink",
value:function(i){
return this.prefetched.add(i.href),
new Promise(function(e,t){
var n=document.createElement("link");
n.rel="prefetch",
n.href=i.href,
n.onload=e,
n.onerror=t,
document.head.appendChild(n)
}).catch(function(){})
}
},{
key:"_prepareUrl",
value:function(e){
if(null===e||"object"!==(void 0===e?"undefined":r(e))||!1 in e||-1===["http:","https:"].indexOf(e.protocol))
return null;
var t=e.href.substring(0,this.config.siteUrl.length),
n=this._getPathname(e.href,t),
i={
original:e.href,
protocol:e.protocol,
origin:t,
pathname:n,
href:t+n
};
return this._isLinkOk(i)?i:null
}
},{
key:"_getPathname",
value:function(e,t){
var n=t?e.substring(this.config.siteUrl.length):e;
return n.startsWith("/")||(n="/"+n),
this._shouldAddTrailingSlash(n)?n+"/":n
}
},{
key:"_shouldAddTrailingSlash",
value:function(e){
return this.config.usesTrailingSlash&&!e.endsWith("/")&&!this.regex.fileExt.test(e)
}
},{
key:"_isLinkOk",
value:function(e){
return null!==e&&"object"===(void 0===e?"undefined":r(e))&&(!this.prefetched.has(e.href)&&e.origin===this.config.siteUrl&&-1===e.href.indexOf("?")&&-1===e.href.indexOf("#")&&!this.regex.excludeUris.test(e.href)&&!this.regex.images.test(e.href))
}
}],
[{
key:"run",
value:function(){
"undefined"!=typeof RocketPreloadLinksConfig&&new n(new RocketBrowserCompatibilityChecker({capture:!0,passive:!0}),RocketPreloadLinksConfig).init()
}
}]),
n
}();
t.run();
}());
```
--------------------------------
### Button Wrapper Flexbox Layout
Source: https://www.assuranceendirect.com/bien-gerer-ses-dettes.html
Configures a button wrapper to use flexbox, allowing items to wrap, align to the start vertically, justify to the start horizontally, and clear floats.
```css
.gb-button-wrapper{
display:flex;
flex-wrap:wrap;
align-items:flex-start;
justify-content:flex-start;
clear:both
}
```
--------------------------------
### JavaScript: Preconnect and Preload Resource Hints
Source: https://www.assuranceendirect.com/paiement-securise-reglez-vos-cotisations-dassurance-en-ligne.html
This code manages the creation of `` elements for `preconnect` and `preload` resource hints. It iterates through a list of scripts, extracts their source URLs, and creates corresponding link tags to optimize resource loading by establishing early connections or pre-fetching resources.
```javascript
O(){this.N([...this.delayedScripts.normal,...this.delayedScripts.defer,...this.delayedScripts.async],"preload")}
N(t,e){this.trash=this.trash||[];let i=!0;var o=document.createDocumentFragment();t.forEach((t=>{const s=t.getAttribute&&t.getAttribute("data-rocket-src")||t.src;if(s&&!s.startsWith("data:")){const n=document.createElement("link");n.href=s,n.rel=e,"preconnect"!==e&&(n.as="script",n.fetchPriority=i?"high":"low"),t.getAttribute&&"module"===t.getAttribute("data-rocket-type")&&(n.crossOrigin=!0),t.crossOrigin&&(n.crossOrigin=t.crossOrigin),t.integrity&&(n.integrity=t.integrity),t.nonce&&(n.nonce=t.nonce),o.appendChild(n),this.trash.push(n),i=!1}})),document.head.appendChild(o)}
W(){this.trash.forEach((t=>t.remove()))}
```
--------------------------------
### Rocket Preload Links Configuration and Execution
Source: https://www.assuranceendirect.com/details-des-differentes-garanties-assurance-cyclo-scooter-proposees.html
This JavaScript snippet defines and executes a utility for preloading links based on a configuration. It includes methods for normalizing URLs, checking for trailing slashes, and validating links to ensure they are safe and relevant for prefetching. The `run` method initializes the preloading process using `RocketBrowserCompatibilityChecker` and `RocketPreloadLinksConfig`.
```JavaScript
this.config.siteUrl.length):e;return n.startsWith("/")||(n="/"+n),this._shouldAddTrailingSlash(n)?n+"/":n}},{key:"_shouldAddTrailingSlash",value:function(e){return this.config.usesTrailingSlash&&!e.endsWith("/")&&!this.regex.fileExt.test(e)}},{key:"_isLinkOk",value:function(e){return null!==e&&"object"===(void 0===e?"undefined":r(e))&&(!this.prefetched.has(e.href)&&e.origin===this.config.siteUrl&&-1===e.href.indexOf("?")&&-1===e.href.indexOf("#")&&!this.regex.excludeUris.test(e.href)&&!this.regex.images.test(e.href))}}],[[{key:"run",value:function(){"undefined"!=typeof RocketPreloadLinksConfig&&new n(new RocketBrowserCompatibilityChecker({capture:!0,passive:!0}),RocketPreloadLinksConfig).init()}}]),n}();t.run(); }());
```
--------------------------------
### Intercepting document.readyState and Initial Setup
Source: https://www.assuranceendirect.com/tabliers-pour-scooter-xmax-125-et-autres-modeles-comparaison-des-differences.html
This snippet shows the initial setup of the WPRocket optimization script. It intercepts the `document.readyState` property to control its value, ensuring that the script can manage when the document is reported as 'loading' or 'complete'. This is a foundational step for controlling subsequent script execution and event firing.
```javascript
e(document,"onreadystatechange"),e(window,"onload"),e(window,"onpageshow");try{Object.defineProperty(document,"readyState",{get:()=>t.rocketReadyState,set(e){t.rocketReadyState=e},configurable:!0}),document.readyState="loading"}catch(t){console.log("WPRocket DJE readyState conflict, bypassing")}
```
--------------------------------
### Resource Preconnect and Preload (RocketLazyLoadScripts.N method)
Source: https://www.assuranceendirect.com/baigneurs-et-jet-ski-quand-la-cohabitation-devient-un-danger.html
The `N` method handles the creation of `` elements for `preconnect` and `preload` hints. It iterates through a list of resources, creates appropriate link tags with attributes like `href`, `rel`, `as`, `fetchPriority`, `crossOrigin`, `integrity`, and `nonce`, then appends them to the document head. This optimizes resource loading by establishing early connections and fetching critical resources ahead of time.
```javascript
N(t,e){this.trash=this.trash||[];let i=!0;var o=document.createDocumentFragment();t.forEach((t=>{const s=t.getAttribute&&t.getAttribute("data-rocket-src")||t.src;if(s&&!s.startsWith("data:")){const n=document.createElement("link");n.href=s,n.rel=e,"preconnect"!==e&&(n.as="script",n.fetchPriority=i?"high":"low"),t.getAttribute&&"module"===t.getAttribute("data-rocket-type")&&(n.crossOrigin=!0),t.crossOrigin&&(n.crossOrigin=t.crossOrigin),t.integrity&&(n.integrity=t.integrity),t.nonce&&(n.nonce=t.nonce),o.appendChild(n),this.trash.push(n),i=!1}})),document.head.appendChild(o)}
```
--------------------------------
### RocketLazyLoadScripts - Initial Setup and Browser-Specific Event Handling
Source: https://www.assuranceendirect.com/garantie-incendie-responsabilite-locataire.html
These methods handle initial setup and specific browser behaviors. `i()` checks for CSP issues, `o()` manages page show/hide events for persistence, and `h()` implements a custom touch event handler for iOS devices to simulate clicks based on touch movement and time, potentially addressing specific event propagation quirks.
```javascript
i(){this.CSPIssue=sessionStorage.getItem("rocketCSPIssue"),document.addEventListener("securitypolicyviolation",(t=>{this.CSPIssue||"script-src-elem"!==t.violatedDirective||"data"!==t.blockedURI||(this.CSPIssue=!0,sessionStorage.setItem("rocketCSPIssue",!0))}),{isRocket:!0})}o(){window.addEventListener("pageshow",(t=>{this.persisted=t.persisted,this.realWindowLoadedFired=!0}),{isRocket:!0}),window.addEventListener("pagehide",(()=>{this.onFirstUserAction=null}),{isRocket:!0})}h(){let t;function e(e){t=e}window.addEventListener("touchstart",e,{isRocket:!0}),window.addEventListener("touchend",(function i(o){Math.abs(o.changedTouches[0].pageX-t.changedTouches[0].pageX)<10&&Math.abs(o.changedTouches[0].pageY-t.changedTouches[0].pageY)<10&&o.timeStamp-t.timeStamp<200&&(o.target.dispatchEvent(new PointerEvent("click",{target:o.target,bubbles:!0,cancelable:!0,detail:1})),event.preventDefault(),window.removeEventListener("touchstart",e,{isRocket:!0}),window.removeEventListener("touchend",i,{isRocket:!0}))}),{isRocket:!0}}
```
--------------------------------
### Rocket Preload Links Configuration and Execution
Source: https://www.assuranceendirect.com/comment-eviter-les-pannes-de-demarrage-sur-un-scooter-125.html
This JavaScript snippet defines and executes logic for preloading links based on a configuration. It includes methods for validating link URLs, normalizing pathnames, handling trailing slashes, and checking link suitability for prefetching. The `run` method initializes the preloading mechanism using `RocketPreloadLinksConfig`.
```javascript
ull===e||"object"!==(void 0===e?"undefined":r(e))||!1 in e||-1===["http:","https:"].indexOf(e.protocol))return null;var t=e.href.substring(0,this.config.siteUrl.length),n=this._getPathname(e.href,t),i={original:e.href,protocol:e.protocol,origin:t,pathname:n,href:t+n};return this._isLinkOk(i)?i:null}},{key:"_getPathname",value:function(e,t){var n=t?e.substring(this.config.siteUrl.length):e;return n.startsWith("/")||(n="/"+n),this._shouldAddTrailingSlash(n)?n+"/":n}},{key:"_shouldAddTrailingSlash",value:function(e){return this.config.usesTrailingSlash&&!e.endsWith("/")&&!this.regex.fileExt.test(e)}},{key:"_isLinkOk",value:function(e){return null!==e&&"object"===(void 0===e?"undefined":r(e))&&(!this.prefetched.has(e.href)&&e.origin===this.config.siteUrl&&-1===e.href.indexOf("?")&&-1===e.href.indexOf("#")&&!this.regex.excludeUris.test(e.href)&&!this.regex.images.test(e.href))}}],[{key:"run",value:function(){"undefined"!=typeof RocketPreloadLinksConfig&&new n(new RocketBrowserCompatibilityChecker({capture:!0,passive:!0}),RocketPreloadLinksConfig).init()}}]),n}();t.run(); }());
```
--------------------------------
### Button Wrapper Justification
Source: https://www.assuranceendirect.com/bien-gerer-ses-dettes.html
Specifically sets the horizontal justification of items within a button wrapper to the start.
```css
.gb-button-wrapper-43e89267{
justify-content:flex-start
}
```
--------------------------------
### iOS Touch Event to Click Conversion
Source: https://www.assuranceendirect.com/trouver-le-tablier-ideal-pour-votre-xmax-125-nos-conseils.html
The `h()` method implements a workaround for iOS devices (iPad/iPhone) to convert specific touch events into a synthetic 'click' event. It captures the start and end coordinates and timestamps of touch events. If a touch ends within a small distance and short time from its start, it dispatches a `PointerEvent` of type 'click' on the target element, preventing the default touch behavior. This ensures click events are reliably triggered on iOS.
```JavaScript
h(){
let t;
function e(e){t=e}
window.addEventListener("touchstart",e,{isRocket:!0}),
window.addEventListener("touchend",(function i(o){
Math.abs(o.changedTouches[0].pageX-t.changedTouches[0].pageX)<10&&
Math.abs(o.changedTouches[0].pageY-t.changedTouches[0].pageY)<10&&
o.timeStamp-t.timeStamp<200&&(
o.target.dispatchEvent(new PointerEvent("click",{target:o.target,bubbles:!0,cancelable:!0,detail:1})),
event.preventDefault(),
window.removeEventListener("touchstart",e,{isRocket:!0}),
window.removeEventListener("touchend",i,{isRocket:!0})
)
}),{isRocket:!0})
}
```
--------------------------------
### Resource Preload and Preconnect Management
Source: https://www.assuranceendirect.com/comment-se-passe-un-jugement-pour-alcool-au-volant.html
The `N(t,e)` method dynamically creates `` elements for resource hints like 'preload' or 'preconnect'. It iterates through a list of scripts, extracts their source URLs, and creates corresponding link tags with appropriate attributes (e.g., `as`, `fetchPriority`, `crossOrigin`, `integrity`, `nonce`).
```javascript
O(){this.N([...this.delayedScripts.normal,...this.delayedScripts.defer,...this.delayedScripts.async],"preload")}
N(t,e){
this.trash=this.trash||[];
let i=!0;
var o=document.createDocumentFragment();
t.forEach((t=>{
const s=t.getAttribute&&t.getAttribute("data-rocket-src")||t.src;
if(s&&!s.startsWith("data:")){
const n=document.createElement("link");
n.href=s,n.rel=e,"preconnect"!==e&&(n.as="script",n.fetchPriority=i?"high":"low"),
t.getAttribute&&"module"===t.getAttribute("data-rocket-type")&&(n.crossOrigin=!0),
t.crossOrigin&&(n.crossOrigin=t.crossOrigin),
t.integrity&&(n.integrity=t.integrity),
t.nonce&&(n.nonce=t.nonce),
o.appendChild(n),this.trash.push(n),i=!1
}
})),
document.head.appendChild(o)
}
```
--------------------------------
### JavaScript: RocketLazyLoadScripts - User Event Listener Setup and Cleanup (u, U methods)
Source: https://www.assuranceendirect.com/obtenir-le-justificatif-de-resiliation-pour-votre-assurance-auto.html
The `u()` method initializes the user event handling by binding the `q` method as the `userEventHandler` and attaching it to a predefined list of `userEvents` on the window. This setup captures initial user interactions. The `U()` method serves as the cleanup function, removing all previously attached user event listeners and then re-dispatching any saved events to their original targets, ensuring that events are processed once the main scripts are loaded.
```javascript
u(){this.savedUserEvents=[],this.userEventHandler=this.q.bind(this),this.userEvents.forEach((t=>window.addEventListener(t,this.userEventHandler,{passive:!1,isRocket:!0})))}U(){this.userEvents.forEach((t=>window.removeEventListener(t,this.userEventHandler,{passive:!1,isRocket:!0}))),this.savedUserEvents.forEach((t=>{t.target.dispatchEvent(new window[t.constructor.name](t.type,t))}))}
```
--------------------------------
### Rocket Preload Links Configuration and Logic
Source: https://www.assuranceendirect.com/assurance-voiture-en-ligne.html
This JavaScript snippet defines methods for a link preloading mechanism. The `_isLinkOk` method validates if a given link is suitable for prefetching based on various criteria like origin, query parameters, and exclusion rules. The `run` method initializes the preloading process, typically after the DOM is ready, using a browser compatibility checker.
```javascript
function(e){return null!==e&&"object"===(void 0===e?"undefined":r(e))&&(!this.prefetched.has(e.href)&&e.origin===this.config.siteUrl&&-1===e.href.indexOf("?")&&-1===e.href.indexOf("#")&&!this.regex.excludeUris.test(e.href)&&!this.regex.images.test(e.href))}
function(){ RocketPreloadLinksConfig&&new n(new RocketBrowserCompatibilityChecker({capture:!0,passive:!0}),RocketPreloadLinksConfig).init()}
```
--------------------------------
### rocket_lazyload_css_data: Lazy Load Configuration
Source: https://www.assuranceendirect.com/location-de-voiture-pour-jeunes-conducteurs-avec-km-illimite.html
Configuration object for the lazy loading script, specifically for background images. It defines the threshold for when elements should start loading relative to the viewport.
```APIDOC
rocket_lazyload_css_data:
threshold: "300"
- Type: string (number)
- Description: The root margin in pixels for the Intersection Observer. Elements will be considered intersecting when they are within this distance from the viewport.
```
--------------------------------
### RocketPreloadLinks Initialization
Source: https://www.assuranceendirect.com/le-bridage-des-moteurs-de-scooter.html
This code snippet initializes the `RocketPreloadLinks` functionality. It checks for the global `RocketPreloadLinksConfig` variable and, if present, creates a new instance of the `n` class (likely `RocketPreloadLinks`) with a `RocketBrowserCompatibilityChecker` and the configuration, then calls its `init()` method to start the link preloading process.
```JavaScript
run: function(){
"undefined" != typeof RocketPreloadLinksConfig && new n(new RocketBrowserCompatibilityChecker({capture:!0,passive:!0}),RocketPreloadLinksConfig).init()
}
```
--------------------------------
### rocket_lazyload_css_data Configuration
Source: https://www.assuranceendirect.com/conducteur-sans-assurance-auto-depuis-trois-ans.html
This small configuration object is used for lazy loading CSS. It specifies a 'threshold' value, likely indicating the distance from the viewport at which CSS should start loading.
```javascript
var rocket_lazyload_css_data = {
"threshold": "300"
};
```
--------------------------------
### Initialize RocketPreloadLinks for Page Optimization
Source: https://www.assuranceendirect.com/loi-chatel-resiliation-de-contrats-d-assurances-tout-connaitre-sur-la-loi-chatel.html
This snippet initializes the RocketPreloadLinks library, which is designed to optimize page loading by preloading links. It includes checks for browser compatibility and utilizes a global configuration object (`RocketPreloadLinksConfig`). The `t.run()` call executes the initialization.
```JavaScript
href.indexOf("?")&&-1===e.href.indexOf("#")&&!this.regex.excludeUris.test(e.href)&&!this.regex.images.test(e.href))}}
],
[
{
key:"run",value:function(){
"undefined"!=typeof RocketPreloadLinksConfig&&new n(new RocketBrowserCompatibilityChecker({capture:!0,passive:!0}),RocketPreloadLinksConfig).init()
}
}
]
),
n
}();
t.run();
}
```
--------------------------------
### Responsive Styles for Min-Width 990px (Desktop)
Source: https://www.assuranceendirect.com/les-differents-pare-brise-de-protection-pour-scooter.html
Defines styles specifically for larger screens (desktop) starting from 990px width. This includes hiding mobile-specific elements and adjusting container padding.
```CSS
@media screen and (min-width:990px){
.avis-clients-mobile{
display:none
}
.appel-mobile{
display:none!important
}
.remonte-titre-cta{
margin-top:0
}
body:has(.category-automobile-malus) .remonte-titre-cta{
margin-top:0
}
body:has(.category-assurance-resiliee) .remonte-titre-cta{
margin-top:0
}
.gb-container-39e13bf9{
padding-top:8px;
background-color:transparent!important
}
.inside-site-info{
padding:13px 37px!important
}
}
```
--------------------------------
### Configure and Initialize RocketPreloadLinks for Link Prefetching
Source: https://www.assuranceendirect.com/comment-bien-freiner-en-scooter.html
This JavaScript snippet defines the configuration object for the RocketPreloadLinks script and then initializes the prefetching mechanism. It sets up rules for URL exclusion, image extensions, file extensions, site URL, hover delay, and rate throttling to control when and what links are prefetched. The `run` method ensures the script only initializes if `RocketPreloadLinksConfig` is defined.
```JavaScript
var RocketPreloadLinksConfig = {"excludeUris":"/|\\/recommends\\/","usesTrailingSlash":"","imageExt":"jpg|jpeg|gif|png|tiff|bmp|webp|avif|pdf|doc|docx|xls|xlsx|php","fileExt":"jpg|jpeg|gif|png|tiff|bmp|webp|avif|pdf|doc|docx|xls|xlsx|php|html|htm","siteUrl":"https:\/\/www.assuranceendirect.com","onHoverDelay":"100","rateThrottle":"3"};
(function() {
"use strict";
var r = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
return typeof e;
} : function(e) {
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
},
e = function() {
function i(e, t) {
for (var n = 0; n < t.length; n++) {
var i = t[n];
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i);
}
}
return function(e, t, n) {
return t && i(e.prototype, t), n && i(e, n), e;
};
}();
function i(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
}
var t = function() {
function n(e, t) {
i(this, n), this.browser = e, this.config = t, this.options = this.browser.options, this.prefetched = new Set, this.eventTime = null, this.threshold = 1111, this.numOnHover = 0;
}
return e(n, [{
key: "init",
value: function() {
!this.browser.supportsLinkPrefetch() || this.browser.isDataSaverModeOn() || this.browser.isSlowConnection() || (this.regex = {
excludeUris: RegExp(this.config.excludeUris, "i"),
images: RegExp(".(" + this.config.imageExt + ")$", "i"),
fileExt: RegExp(".(" + this.config.fileExt + ")$", "i")
}, this._initListeners(this));
}
}, {
key: "_initListeners",
value: function(e) {
-1 < this.config.onHoverDelay && document.addEventListener("mouseover", e.listener.bind(e), e.listenerOptions), document.addEventListener("mousedown", e.listener.bind(e), e.listenerOptions), document.addEventListener("touchstart", e.listener.bind(e), e.listenerOptions);
}
}, {
key: "listener",
value: function(e) {
var t = e.target.closest("a"),
n = this._prepareUrl(t);
if (null !== n) switch (e.type) {
case "mousedown":
case "touchstart":
this._addPrefetchLink(n);
break;
case "mouseover":
this._earlyPrefetch(t, n, "mouseout");
}
}
}, {
key: "_earlyPrefetch",
value: function(t, e, n) {
var i = this,
r = setTimeout(function() {
if (r = null, 0 === i.numOnHover) setTimeout(function() {
return i.numOnHover = 0;
}, 1e3); else if (i.numOnHover > i.config.rateThrottle) return;
i.numOnHover++, i._addPrefetchLink(e);
}, this.config.onHoverDelay);
t.addEventListener(n, function e() {
t.removeEventListener(n, e, {
passive: !0
}), null !== r && (clearTimeout(r), r = null);
}, {
passive: !0
});
}
}, {
key: "_addPrefetchLink",
value: function(i) {
return this.prefetched.add(i.href), new Promise(function(e, t) {
var n = document.createElement("link");
n.rel = "prefetch", n.href = i.href, n.onload = e, n.onerror = t, document.head.appendChild(n);
}).catch(function() {});
}
}, {
key: "_prepareUrl",
value: function(e) {
if (null === e || "object" !== (void 0 === e ? "undefined" : r(e)) || !1 in e || -1 === ["http:", "https:"].indexOf(e.protocol)) return null;
var t = e.href.substring(0, this.config.siteUrl.length),
n = this._getPathname(e.href, t),
i = {
original: e.href,
protocol: e.protocol,
origin: t,
pathname: n,
href: t + n
};
return this._isLinkOk(i) ? i : null;
}
}, {
key: "_getPathname",
value: function(e, t) {
var n = t ? e.substring(this.config.siteUrl.length) : e;
return n.startsWith("/") || (n = "/" + n), this._shouldAddTrailingSlash(n) ? n + "/" : n;
}
}, {
key: "_shouldAddTrailingSlash",
value: function(e) {
return this.config.usesTrailingSlash && !e.endsWith("/") && !this.regex.fileExt.test(e);
}
}, {
key: "_isLinkOk",
value: function(e) {
return null !== e && "object" === (void 0 === e ? "undefined" : r(e)) && (!this.prefetched.has(e.href) && e.origin === this.config.siteUrl && -1 === e.href.indexOf("?") && -1 === e.href.indexOf("#") && !this.regex.excludeUris.test(e.href) && !this.regex.images.test(e.href));
}
}], [{
key: "run",
value: function() {
"undefined" != typeof RocketPreloadLinksConfig && new n(new RocketBrowserCompatibilityChecker({
capture: !0,
passive: !0
}), RocketPreloadLinksConfig).init();
}
}]), n;
}();
t.run();
}());
```
--------------------------------
### RocketLazyLoadScripts: Initialization and Execution
Source: https://www.assuranceendirect.com/comment-connaitre-son-bonus-assurance.html
This snippet contains the static `run` method that initializes and starts the `RocketLazyLoadScripts` class, along with a recursive method `C` that processes a queue of scripts, ensuring each is connected and then loaded.
```javascript
async C(t){const e=t.shift();return e?(e.isConnected&&await this.$(e),this.C(t)):Promise.resolve()}
static run(){(new RocketLazyLoadScripts).t()}RocketLazyLoadScripts.run()})();
```