### Setup WordLift Notebook (Shell) Source: https://docs.wordlift.io/ Clones the WordLift getting-started-notebook repository, installs dependencies using Poetry, and runs the Jupyter notebook. This setup allows users to explore and jumpstart a Knowledge Graph. Requires Git, Poetry, and Jupyter Notebook. ```shell # Clone the repository git clone https://github.com/wordlift/getting-started-notebook.git cd getting-started-notebook # Install dependencies using Poetry poetry install # Configure with your WordLift Key and sitemap URL # Then run the notebook jupyter notebook getting_started_notebook.ipynb ``` -------------------------------- ### Install WordLift Python Client Source: https://docs.wordlift.io/ Provides instructions for installing the WordLift client library for Python, enabling custom development and integration with WordLift services. Supports Python, Node.js, and PHP clients. ```bash pip install wordlift-client ``` -------------------------------- ### Install WordLift Client (Python) Source: https://docs.wordlift.io/ Installs the WordLift Python client library using pip. This is the primary method for developers to integrate WordLift functionality into their Python projects. Requires Python and pip to be installed. ```python pip install wordlift-client ``` -------------------------------- ### WordLift Developer Documentation and API Guides Source: https://wordlift.io/free-ai-seo-tools/ Access comprehensive guides and documentation for integrating WordLift products and APIs. This resource provides developers with the necessary information to leverage WordLift's AI capabilities for SEO and content optimization. ```APIDOC WordLift API Documentation: Overview: Provides detailed information for developers integrating WordLift solutions. Covers API endpoints, authentication, data structures, and best practices for leveraging AI in SEO. Key Sections: - Getting Started: Initial setup and authentication. - API Reference: Detailed descriptions of available API endpoints and methods. - Dev Guides: Tutorials and practical examples for common integration scenarios. - API Status: Real-time updates on service performance and availability. Resources: - Documentation Portal: https://docs.wordlift.io/ - API Category: https://docs.wordlift.io/category/api/ Purpose: To enable developers to build applications and services that utilize WordLift's AI-driven SEO and content intelligence features. ``` -------------------------------- ### JavaScript GTMKit Data Initialization Source: https://wordlift.io/pricing/ Initializes the GTMKit data object, which is likely used to store and pass data to Google Tag Manager. It starts as an empty object. ```javascript window.gtmkit_data = {}; ``` -------------------------------- ### WordLift Global Settings Initialization Source: https://wordlift.io/about-us/ Initializes global JavaScript variables `wlSettings` and `_wlCloudSettings`. These objects contain configuration details such as API endpoints and JSON-LD URLs necessary for WordLift's functionality. ```JavaScript var wlSettings = {"ajaxUrl":"https:\/\/wordlift.io\/wp-admin\/admin-ajax.php","apiUrl":"https:\/\/wordlift.io\/wl-api\/","jsonld_url":"https:\/\/wordlift.io\/wp-json\/wordlift\/v1\/jsonld\/","postId":"17441","jsonld_enabled":""}; var _wlCloudSettings = {"selector":"a.wl-entity-page-link","url":"https:\/\/wordlift.io\/wp-json\/wordlift\/v1\/jsonld"}; ``` -------------------------------- ### WordPress Localization Setup Source: https://wordlift.io/press/ Sets the locale data for WordPress internationalization (i18n). This specific entry configures the text direction for the 'ltr' locale. ```javascript wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ 'ltr' ] } ); ``` -------------------------------- ### Module Loader and Definitions Source: https://wordlift.io/pricing/ This snippet appears to be part of a JavaScript module bundler's output (like Webpack). It defines functions for module loading (`o.m`, `o.amdO`), module registration (`o.O`), defining properties (`o.d`), and checking property existence (`o.o`). This is foundational for managing dependencies and code execution in a larger application. ```javascript !function() { "use strict"; var e, r = {}, n = {}; function o(e) { var t = n[e]; if (void 0 !== t) return t.exports; var u = n[e] = { exports: {} }; return r[e].call(u.exports, u, u.exports, o), u.exports } o.m = r, o.amdO = {}, e = [], o.O = function(r, n, t, u) { if (!n) { var i = 1 / 0; for (l = 0; l < e.length; l++) { n = e[l][0], t = e[l][1], u = e[l][2]; for (var f = !0, a = 0; a < n.length; a++) (!1 & u || i >= u) && Object.keys(o.O).every((function(e) { return o.O[e](n[a]) })) ? n.splice(a--, 1) : (f = !1, u < i && (i = u)); if (f) { e.splice(l--, 1); var c = t(); void 0 !== c && (r = c) } } return r } u = u || 0; for (var l = e.length; l > 0 && e[l - 1][2] > u; l--) e[l] = e[l - 1]; e[l] = [n, t, u] }, o.d = function(e, r) { for (var n in r) o.o(r, n) && !o.o(e, n) && Object.defineProperty(e, n, { enumerable: !0, get: r[n] }) }, o.o = function(e, r) { return Object.prototype.hasOwnProperty.call(e, r) } }() ``` -------------------------------- ### Rocket Preload Links Implementation Source: https://wordlift.io/case-studies/ Implements a link prefetching strategy that listens for mouseover, mousedown, and touchstart events. It intelligently preloads links based on configuration, avoiding exclusions and optimizing resource loading. ```javascript var RocketPreloadLinks = function() { var e = "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 }, t = 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(t, n, r) { return n && i(t.prototype, n), r && i(t, r), t } }(); function i(e, t) { if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") } var n = 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 t(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() { r = null, 0 === i.numOnHover ? setTimeout(function() { return i.numOnHover = 0 }, 1e3) : i.numOnHover > i.config.rateThrottle || (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" : 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" : 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(); ``` -------------------------------- ### WordPress Internationalization Setup Source: https://wordlift.io/partnership/ Sets the locale data for WordPress internationalization (i18n) functions, specifically defining the text direction for the current locale. ```javascript wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ 'ltr' ] } ); ``` -------------------------------- ### WordPress Internationalization Setup Source: https://wordlift.io/free-ai-seo-tools/ Sets the locale data for WordPress internationalization (i18n) functions, specifically defining the text direction for the current locale. ```javascript wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ 'ltr' ] } ); ``` -------------------------------- ### WordLift Settings and Cloud Settings Initialization Source: https://wordlift.io/free-ai-seo-tools/ JavaScript code that initializes global settings for WordLift, including AJAX URLs, API endpoints, JSON-LD URLs, and post IDs. It also sets up settings for the WordLift Cloud feature, specifying a selector for entity links and the URL for JSON-LD data. ```javascript var wlSettings = {"ajaxUrl":"https:\/\/wordlift.io\/wp-admin\/admin-ajax.php","apiUrl":"https:\/\/wordlift.io\/wl-api\/","jsonld_url":"https:\/\/wordlift.io\/wp-json\/wordlift\/v1\/jsonld\/","postId":"166889","jsonld_enabled":""}; var _wlCloudSettings = {"selector":"a.wl-entity-page-link","url":"https:\/\/wordlift.io\/wp-json\/wordlift\/v1\/jsonld"}; ``` -------------------------------- ### Link Preloading Implementation Source: https://wordlift.io/careers/ JavaScript class that implements link prefetching based on user interactions like mouseover, mousedown, and touchstart. It uses a configuration object and browser compatibility checks to decide when and what to prefetch, aiming to speed up navigation. ```javascript 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}; var 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))||"!"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(); ``` -------------------------------- ### Google Tag Manager Initialization Source: https://wordlift.io/press/ Initializes Google Tag Manager by dynamically creating a script tag and pushing initial dataLayer content. This snippet ensures proper tracking setup for web analytics. ```javascript var wpml_cookies = {"wp-wpml_current_language":{"value":"en","expires":1,"path":"\/"}}; window.gtmkit_settings = {"datalayer_name":"dataLayer","console_log":false}; window.gtmkit_data = {}; window.dataLayer = window.dataLayer || []; /* Google Tag Manager */ (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-WM7FBGJ'); /* End Google Tag Manager */ const gtmkit_dataLayer_content = {"pageType":"page"}; dataLayer.push( gtmkit_dataLayer_content ); ``` -------------------------------- ### Link Prefetching and Browser Compatibility Source: https://wordlift.io/academy/ Implements a system to prefetch links based on user interaction (hover, click, touch) to improve perceived page load speed. It includes browser compatibility checks and configurable exclusion rules for specific URIs and file types. The system initializes automatically if the configuration is present. ```javascript var RocketBrowserCompatibilityChecker = function() { var e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) { return void 0 === e ? "undefined" : typeof e; } : function(e) { return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : void 0 === e ? "undefined" : typeof e; }; var t = function() { function i(e, t) { for (var n = 0; n < t.length; n++) { var r = t[n]; r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r); } } 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 n = 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 t(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() { r = null, 0 === i.numOnHover ? setTimeout(function() { return i.numOnHover = 0; }, 1e3) : i.numOnHover > i.config.rateThrottle ? void 0 : (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" : 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" : 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; }(); n.run(); } ``` -------------------------------- ### YouTube Lazy Load Player Setup Source: https://wordlift.io/partnership/ Attaches event listeners to all elements with the class 'rll-youtube-player' on DOMContentLoaded. It creates a div with the thumbnail and play button, and binds the `lazyLoadYoutubeIframe` function to the play button click. ```javascript document.addEventListener("DOMContentLoaded",function(){ var exclusions=["logo.svg"]; var e,t,p,u,l,a=document.getElementsByClassName("rll-youtube-player"); for(t=0;tu.includes(exclusion))), e.setAttribute("data-id",a[t].dataset.id), e.setAttribute("data-query",a[t].dataset.query), e.setAttribute("data-src",a[t].dataset.src), (e.innerHTML=lazyLoadThumb(a[t].dataset.id,a[t].dataset.alt,l)), a[t].appendChild(e), (p=e.querySelector(".play")), (p.onclick=lazyLoadYoutubeIframe) } }); ``` -------------------------------- ### Google Tag Manager Initialization Source: https://wordlift.io/partnership/ This JavaScript snippet initializes Google Tag Manager by pushing a 'gtm.js' event. It dynamically loads the GTM script into the document, ensuring proper tracking setup for the website. ```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-WM7FBGJ'); ``` -------------------------------- ### Rocket Preload Links Initialization Source: https://wordlift.io/ Initializes the Rocket Preload Links functionality. This script enhances website performance by prefetching links based on user interaction and browser capabilities, respecting exclusion rules and site configuration. It checks for browser support, data saver mode, and connection speed before activating. ```javascript var RocketPreloadLinksConfig = { "excludeUris": "\\/add-on-stack\\/|\/(?:.+\/)?feed(?:\/(?:.+\/?)?)?$\|\/(?:.+\/)?embed\/|http:\/\/(\/%5B\/%5D+)?\/(index.php\/)?(.*)wp-json(\/.*|$)|\/refer\/|\/go\/|\/recommend\/|\/recommends\/", "usesTrailingSlash": "1", "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:\/\/wordlift.io", "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 }; var 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(); }()); ``` -------------------------------- ### YouTube Lazy Load Player Setup Source: https://wordlift.io/free-ai-seo-tools/ Attaches event listeners to all elements with the class 'rll-youtube-player' on DOMContentLoaded. It creates a div with the thumbnail and play button, and binds the `lazyLoadYoutubeIframe` function to the play button click. ```javascript document.addEventListener("DOMContentLoaded",function(){ var exclusions=["logo.svg"]; var e,t,p,u,l,a=document.getElementsByClassName("rll-youtube-player"); for(t=0;tu.includes(exclusion))), e.setAttribute("data-id",a[t].dataset.id), e.setAttribute("data-query",a[t].dataset.query), e.setAttribute("data-src",a[t].dataset.src), (e.innerHTML=lazyLoadThumb(a[t].dataset.id,a[t].dataset.alt,l)), a[t].appendChild(e), (p=e.querySelector(".play")), (p.onclick=lazyLoadYoutubeIframe) } }); ``` -------------------------------- ### RocketLazyLoadScripts Initialization and Event Handling (JavaScript) Source: https://wordlift.io/case-studies/ Manages the lifecycle of script loading and document readiness for lazy loading. It dispatches custom events like 'rocket-readystatechange' and 'rocket-DOMContentLoaded' to signal various stages of page loading, ensuring compatibility with other scripts and frameworks. Includes methods for handling document state changes and window load events. ```javascript async J(){try{document.readyState="interactive"}catch(t){}await this.G(),document.dispatchEvent(new Event("rocket-readystatechange")),await this.G(),document.rocketonreadystatechange&&document.rocketonreadystatechange(),await this.G(),document.dispatchEvent(new Event("rocket-DOMContentLoaded")),await this.G(),window.dispatchEvent(new Event("rocket-DOMContentLoaded"))}async J(){try{document.readyState="complete"}catch(t){}await this.G(),document.dispatchEvent(new Event("rocket-readystatechange")),await this.G(),document.rocketonreadystatechange&&document.rocketonreadystatechange(),await this.G(),window.dispatchEvent(new Event("rocket-load")),await this.G(),window.rocketonload&&window.rocketonload(),await this.G(),this.allJQueries.forEach((t=>t(window).trigger("rocket-jquery-load"))),await this.G();const t=new Event("rocket-pageshow");t.persisted=this.persisted,window.dispatchEvent(t),await this.G(),window.rocketonpageshow&&window.rocketonpageshow({persisted:this.persisted}),this.windowLoaded=!0}m(){document.onreadystatechange&&document.onreadystatechange(),window.onload&&window.onload(),window.onpageshow&&window.onpageshow({persisted:this.persisted})}I(){const t=new Map;document.write=document.writeln=function(e){const i=document.currentScript;i||console.error("WPRocket unable to document.write this: "+e);const o=document.createRange(),s=i.parentElement;let n=t.get(i);void 0===n&&(n=i.nextSibling,t.set(i,n));const c=document.createDocumentFragment();o.setStart(c,0),c.appendChild(o.createContextualFragment(e)),s.insertBefore(c,n)}}async G(){Date.now()-this.lastBreath>45&&(await this.K(),this.lastBreath=Date.now())}async K(){return document.hidden?new Promise((t=>setTimeout(t))):new Promise((t=>requestAnimationFrame(t)))}N(){this.trash.forEach((t=>t.remove()))}static run(){const t=new RocketLazyLoadScripts;t.p(t)}}RocketLazyLoadScripts.run()(); ``` -------------------------------- ### Google Tag Manager Integration Source: https://wordlift.io/free-ai-seo-tools/ This snippet configures Google Tag Manager (GTM) for the website. It initializes the data layer, pushes page-specific content data, and asynchronously loads the GTM script. This setup is crucial for tracking website events and analytics. ```javascript var wpml_cookies = {"wp-wpml_current_language":{"value":"en","expires":1,"path":"\/"}}; var wpml_cookies = {"wp-wpml_current_language":{"value":"en","expires":1,"path":"\/"}}; window.gtmkit_settings = {"datalayer_name":"dataLayer","console_log":false}; window.gtmkit_data = {}; window.dataLayer = window.dataLayer || []; /* Google Tag Manager */ (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-WM7FBGJ'); /* End Google Tag Manager */ const gtmkit_dataLayer_content = {"pageType":"page"}; dataLayer.push( gtmkit_dataLayer_content ); ``` -------------------------------- ### Rocket Preload Links Configuration Source: https://wordlift.io/case-studies/ Configuration object for the Rocket Preload Links script. It defines exclusions, file extensions, site URL, and timing parameters for prefetching links to optimize page load times. ```javascript var RocketPreloadLinksConfig = { "excludeUris": "\\/add-on-stack\\/|\/(?:.+\/)?feed(?:\/(?:.+\/?)?)?$" + "|\/(?:.+\/)?embed\/|http:\/\/(\/%5B\/%5D+)?\/(index.php\/)?(.*)wp-json(\/.*|$)|\/refer\/|\/go\/|\/recommend\/|\/recommends\/", "usesTrailingSlash": "1", "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:\/\/wordlift.io", "onHoverDelay": "100", "rateThrottle": "3" }; ``` -------------------------------- ### Mailchimp Form Styling and Utility Classes Source: https://wordlift.io/contact-us/ A collection of CSS rules designed to style Mailchimp forms, including input fields, buttons, and error messages, with a focus on semantic guide and responsiveness. It also includes general utility classes for margin and padding control. ```css /* HACK: fix footer banner position when wp rocket is enabled */ div.layout-wrapper:has(.footer-cta-card) { background: none; z-index: 1; padding-top: 1px; } #main #mc_embed_signup { width: 100%; } #main #mc_embed_signup form { margin: 0; } .bg-primary #mc_embed_signup { background: none; } .bg-primary #mc_embed_signup input:not([type=submit]) { background: #fff; color: var(--neutral-950); } .bg-primary #mc_embed_signup #mc-embedded-subscribe-form div.mce_inline_error { background: #d65472; color: #fff; border-radius: 8px; padding: 8px; margin-top: 4px; } .bg-primary #mc_embed_signup div#mce-responses { margin: 0; padding: 0; margin-bottom: 24px; } .bg-primary #mc_embed_signup div#mce-responses .response { margin: 0; padding: 12px; color: #fff; border-radius: 12px; } .bg-primary #mc_embed_signup div#mce-responses .response#mce-success-response { background: #23a286; } .bg-primary #mc_embed_signup div#mce-responses .response#mce-error-response { background: #d65472; } .mc-field-group label.checkbox input[type=checkbox] { position: static; opacity: 1; } /*** UTILITY CLASSES ***/ /** Overline Text **/ body .overline { font-family: var(--font-family-dm-mono); font-weight: var(--font-weight-regular); line-height: var(--line-height-mobile-sm); text-transform: uppercase; color: var(--neutral-800); } body .overline.overline-sm { font-size: var(--font-size-xs); } body .overline.overline-md { font-size: var(--font-size-sm); } /** Margin Classes **/ .no-margin { margin: 0!important; } .no-margin-v { margin-top: 0!important; margin-bottom: 0!important; } .no-margin-top { margin-top: 0!important; } .no-margin-bottom { margin-bottom: 0!important; } .no-margin-h { margin-left: 0!important; margin-right: 0!important; } .no-margin-left { margin-left: 0!important; } .no-margin-right { margin-right: 0!important; } /** Padding Classes **/ .no-padding { padding: 0!important; } .no-padding-v { padding-top: 0!important; padding-bottom: 0!important; } .no-padding-top { padding-top: 0!important; } .no-padding-bottom { padding-bottom: 0!important; } .no-padding-h { padding-left: 0!important; padding-right: 0!important; } .no-padding-left { padding-left: 0!important; } .no-padding-right { padding-right: 0!important; } /*** FORM - Mailchimp Semantic Guide ***/ .signup_seo_semantica#mc_embed_signup { background: transparent; font-family: var(--font-family-open-sauce); font-size: var(--font-size-base); } .signup_seo_semantica#mc_embed_signup form { padding: 0; } .signup_seo_semantica#mc_embed_signup input.has-default-bkg { font-family: var(--font-family-open-sauce); font-size: var(--font-size-base); background: var(--white-07); border-color: var(--neutral-400); width: 100%; border-radius: 12px; box-sizing: border-box; padding: 12px 16px; } .signup_seo_semantica#mc_embed_signup input.has-default-bkg:hover { background: var(--white-09); border-color: var(--neutral-500); } .signup_seo_semantica#mc_embed_signup input.has-default-bkg:focus { background: var(--white); border-color: var(--neutral-700); } .signup_seo_semantica#mc_embed_signup input.button { font-family: var(--font-family-open-sauce-bold); font-size: var(--font-size-base); background-color: var(--sky-500); width: auto; height: auto; align-items: center; border-radius: 12px; box-sizing: border-box; cursor: pointer; justify-content: center; overflow: hidden; padding: 10px 16px; text-align: center; } .signup_seo_semantica#mc_embed_signup input.button:hover { background-color: var(--sky-600); } ```