# How to extract the cube root in Python

The cube root of a number is a value that, when multiplied by a cube, yields the original number. In other words, the cube root is the value that, when multiplied by three times, gives us the number under the root. The cube root is denoted by the symbol “3√”. In the case of the square root, we have only used the symbol ‘√’ without specifying the degree, which is also called the radical. For example, the cube root of 125, denoted as 3√125, is 5 because multiplying 5 by itself three times yields 5 x 5 x 5 = 125 = 5^3.

## The Cube Root in Python

To calculate the cube root in Python, use a simple mathematical expression x ** (1. / 3.), the result of which is the cube root of x as a floating point value. To check if the extraction operation is correct, round the result to the nearest whole number and take it to the third power, then compare whether the result is equal to x.
x = 8
cube_root = x ** (1./3.)
print(cube_root)
Output ` 2.0 In Python, we use the ** operator to raise a number to a power. Specifying a power of 1/3 in an expression with ** allows us to get the cube root of a given number.`

` Extracting the cube root from a negative number in Python `

`We cannot extract the cube root from negative numbers using the above method. For example, the cube root of the integer -64 should be -4, but Python returns 2+3.4641016157754j. To find the cube root of a negative number in Python, you first need to use the abs() function, and then you can use the simple expression with ** presented earlier to calculate it. Let's write a full function that checks to see if the input number is negative and then calculates its cube root accordingly. def get_cube_root(x): if x < 0: x = abs(x) cube_root = x**(1/3)*(-1) else: cube_root = x**(1/3) return cube_root print(round(get_cube_root(64)) print(get_cube_root(-64)) ` Output ` 4 -3.9999999999999996 As you can see, we need to round the result to get the integer value of the cube root.`

` Using the Numpy function cbrt() `

`The numpy library offers another way to find the cube root in Python, which is to use the cbrt() method. The np.cbrt() function calculates the cube root for each element of the array passed to it. import numpy as np cubes = [125, -64, 27, -8, 1] cube_roots = np.cbrt(cubes) print(cube_roots) ` Output ` [ 5. -4. 3. -2. 1.] The np.cbrt() function is the simplest way to get the cube root of a number. It has no problem with negative input data and returns an integer number, e.g. -4 for the number -64 passed as argument, unlike the above approaches.`

` You Might Be Interested In Built-in Scikit-Learn datasets for machine learning 8 examples of using value_counts from Pandas A guide to using the split method in Python An example of connection pooling in PostgreSQL using Psycopg2 Tic-tac-toe in python Django Blog #27: Getting Similar Posts `
` `
` 0 comment 0 FacebookTwitterPinterestEmail Alex My name is Alexey Krasovsky, I am a lead programmer, a certified Python specialist and, at the same time, the author of this blog. previous post How to execute PL/SQL expressions and procedures in Python next post Django + AJAX: How to use AJAX in Django templates Related Posts Оператор за форматиране на низове – Оператор % 14.09.2022 Description of the range function with examples for... 03.08.2022 The main features of the Python Imaging Library... 03.08.2022 Soccer Telegram bot in Python (3/4): Getting external... 03.08.2022 Soccer Telegram bot in Python (1/4): Preparing and... 03.08.2022 Top 10 Python Libraries for Machine Learning 03.08.2022 Outputting text in python with print() 01.08.2022 JSON Python module for working with .json format 01.08.2022 An example of connection pooling in PostgreSQL using... 01.08.2022 Seaborn for data visualization in Python 01.08.2022 LEAVE A COMMENT Save my name, email, and website in this browser for the next time I comment. `
` `
` `
` Recent Posts Math Python – Python Math Operations Library Python Print – Python print function Python Interpreters, Compilers, Translators Input Python – keyboard input Оператор за форматиране на низове – Оператор % Recent CommentsKeep in touch Facebook Twitter Instagram Pinterest Youtube Snapchat Rss Recent Posts Math Python – Python Math Operations Library Python Print – Python print function Python Interpreters, Compilers, Translators Input Python – keyboard input Categories Basics (102) Development environment (8) Examples (90) Lessons (34) Other (18) `
` `
` `
` Facebook Twitter Instagram Linkedin Youtube Snapchat Telegram `
``` Home Development environment Basics Examples Other About Contact Install Python Install PyCharm What is Python Best frameworks Getting Started Examples Popular Posts 1 CSV in Python 2 How to work with matrices in Python 3 Python lists – Python list() functions and methods 4 Django Blog #23: Creating a Commenting System 5 Django Blog #25: Adding Comments to a Post Template 6 Python comments @2022 - All Right Reserved. Realpython.world We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies. Do not sell my personal information.Cookie SettingsAcceptManage consent Privacy Overview This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience. Necessary Necessary Always Enabled Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously. CookieDurationDescriptioncookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. Functional Functional Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features. Performance Performance Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors. Analytics Analytics Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc. Advertisement Advertisement Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads. Others Others Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet. SAVE & ACCEPT .cookielawinfo-column-1{width:25%;}.cookielawinfo-column-3{width:15%;}.cookielawinfo-column-4{width:50%;}table.cookielawinfo-winter{font:85% "Lucida Grande","Lucida Sans Unicode","Trebuchet MS",sans-serif;padding:0;margin:10px 0 20px;border-collapse:collapse;color:#333;background:#f3f5f7;}table.cookielawinfo-winter a{color:#3a4856;text-decoration:none;border-bottom:1px solid #c6c8cb;}table.cookielawinfo-winter a:visited{color:#777;}table.cookielawinfo-winter a:hover{color:#000;}table.cookielawinfo-winter thead th{background:#3a4856;padding:15px 10px;color:#fff;text-align:left;font-weight:normal;}table.cookielawinfo-winter tbody{border-left:1px solid #eaecee;border-right:1px solid #eaecee;}table.cookielawinfo-winter tbody{border-bottom:1px solid #eaecee;}table.cookielawinfo-winter tbody td,table.cookielawinfo-winter tbody th{padding:10px;background:url("https://realpython.world/wp-content/plugins/cookie-law-info/public/css/cookie-law-info-table.css../../images/td_back.gif") repeat-x;text-align:left;}table.cookielawinfo-winter tbody tr{background:#f3f5f7;}table.cookielawinfo-winter tbody tr:hover{background:#eaecee;color:#111;}@media (max-width:800px) { table.cookielawinfo-row-cat-table td,table.cookielawinfo-row-cat-table th{width:23%;font-size:12px;word-wrap:break-word;}table.cookielawinfo-row-cat-table .cookielawinfo-column-4,table.cookielawinfo-row-cat-table .cookielawinfo-column-4{width:45%;} }.cookielawinfo-row-cat-table{width:99%;margin-left:5px;} /* <![CDATA[ */ var wpcf7 = {"api":{"root":"https:\/\/realpython.world\/wp-json\/","namespace":"contact-form-7\/v1"}}; /* ]]> */ /* <![CDATA[ */ var ajax_var_more = {"url":"https:\/\/realpython.world\/wp-admin\/admin-ajax.php","nonce":"2529ab99a2","errorPass":"<p class=\"message message-error\">Password does not match the confirm password<\/p>","login":"Email Address","password":"Password","headerstyle":"default"}; /* ]]> */ /* <![CDATA[ */ var ajax_var = {"url":"https:\/\/realpython.world\/wp-admin\/admin-ajax.php","nonce":"2529ab99a2","errorPass":"<p class=\"message message-error\">Password does not match the confirm password<\/p>","login":"Email Address","password":"Password","headerstyle":"default"}; /* ]]> */ /* <![CDATA[ */ var ezTOC = {"smooth_scroll":"1","visibility_hide_by_default":"1","width":"100%","scroll_offset":"30"}; /* ]]> */ (function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)}; m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)}) (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym"); ym(88027057, "init", { clickmap:true, trackLinks:true, accurateTrackBounce:true, webvisor:true }); !function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalThis?globalThis:n||self).LazyLoad=t()}(this,(function(){"use strict";function n(){return n=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},n.apply(this,arguments)}var t="undefined"!=typeof window,e=t&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),i=t&&"IntersectionObserver"in window,o=t&&"classList"in document.createElement("p"),a=t&&window.devicePixelRatio>1,r={elements_selector:".lazy",container:e||t?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_poster:"poster",class_applied:"applied",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_entered:"entered",class_exited:"exited",unobserve_completed:!0,unobserve_entered:!1,cancel_on_exit:!0,callback_enter:null,callback_exit:null,callback_applied:null,callback_loading:null,callback_loaded:null,callback_error:null,callback_finish:null,callback_cancel:null,use_native:!1},c=function(t){return n({},r,t)},u=function(n,t){var e,i="LazyLoad::Initialized",o=new n(t);try{e=new CustomEvent(i,{detail:{instance:o}})}catch(n){(e=document.createEvent("CustomEvent")).initCustomEvent(i,!1,!1,{instance:o})}window.dispatchEvent(e)},l="src",s="srcset",f="sizes",d="poster",_="llOriginalAttrs",g="loading",v="loaded",b="applied",p="error",h="native",m="data-",E="ll-status",I=function(n,t){return n.getAttribute(m+t)},y=function(n){return I(n,E)},A=function(n,t){return function(n,t,e){var i="data-ll-status";null!==e?n.setAttribute(i,e):n.removeAttribute(i)}(n,0,t)},k=function(n){return A(n,null)},L=function(n){return null===y(n)},w=function(n){return y(n)===h},x=[g,v,b,p],O=function(n,t,e,i){n&&(void 0===i?void 0===e?n(t):n(t,e):n(t,e,i))},N=function(n,t){o?n.classList.add(t):n.className+=(n.className?" ":"")+t},C=function(n,t){o?n.classList.remove(t):n.className=n.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|\$)")," ").replace(/^\s+/,"").replace(/\s+\$/,"")},M=function(n){return n.llTempImage},z=function(n,t){if(t){var e=t._observer;e&&e.unobserve(n)}},R=function(n,t){n&&(n.loadingCount+=t)},T=function(n,t){n&&(n.toLoadCount=t)},G=function(n){for(var t,e=[],i=0;t=n.children[i];i+=1)"SOURCE"===t.tagName&&e.push(t);return e},D=function(n,t){var e=n.parentNode;e&&"PICTURE"===e.tagName&&G(e).forEach(t)},V=function(n,t){G(n).forEach(t)},F=[l],j=[l,d],P=[l,s,f],S=function(n){return!!n[_]},U=function(n){return n[_]},\$=function(n){return delete n[_]},q=function(n,t){if(!S(n)){var e={};t.forEach((function(t){e[t]=n.getAttribute(t)})),n[_]=e}},H=function(n,t){if(S(n)){var e=U(n);t.forEach((function(t){!function(n,t,e){e?n.setAttribute(t,e):n.removeAttribute(t)}(n,t,e[t])}))}},B=function(n,t,e){N(n,t.class_loading),A(n,g),e&&(R(e,1),O(t.callback_loading,n,e))},J=function(n,t,e){e&&n.setAttribute(t,e)},K=function(n,t){J(n,f,I(n,t.data_sizes)),J(n,s,I(n,t.data_srcset)),J(n,l,I(n,t.data_src))},Q={IMG:function(n,t){D(n,(function(n){q(n,P),K(n,t)})),q(n,P),K(n,t)},IFRAME:function(n,t){q(n,F),J(n,l,I(n,t.data_src))},VIDEO:function(n,t){V(n,(function(n){q(n,F),J(n,l,I(n,t.data_src))})),q(n,j),J(n,d,I(n,t.data_poster)),J(n,l,I(n,t.data_src)),n.load()}},W=["IMG","IFRAME","VIDEO"],X=function(n,t){!t||function(n){return n.loadingCount>0}(t)||function(n){return n.toLoadCount>0}(t)||O(n.callback_finish,t)},Y=function(n,t,e){n.addEventListener(t,e),n.llEvLisnrs[t]=e},Z=function(n,t,e){n.removeEventListener(t,e)},nn=function(n){return!!n.llEvLisnrs},tn=function(n){if(nn(n)){var t=n.llEvLisnrs;for(var e in t){var i=t[e];Z(n,e,i)}delete n.llEvLisnrs}},en=function(n,t,e){!function(n){delete n.llTempImage}(n),R(e,-1),function(n){n&&(n.toLoadCount-=1)}(e),C(n,t.class_loading),t.unobserve_completed&&z(n,e)},on=function(n,t,e){var i=M(n)||n;nn(i)||function(n,t,e){nn(n)||(n.llEvLisnrs={});var i="VIDEO"===n.tagName?"loadeddata":"load";Y(n,i,t),Y(n,"error",e)}(i,(function(o){!function(n,t,e,i){var o=w(t);en(t,e,i),N(t,e.class_loaded),A(t,v),O(e.callback_loaded,t,i),o||X(e,i)}(0,n,t,e),tn(i)}),(function(o){!function(n,t,e,i){var o=w(t);en(t,e,i),N(t,e.class_error),A(t,p),O(e.callback_error,t,i),o||X(e,i)}(0,n,t,e),tn(i)}))},an=function(n,t,e){!function(n){n.llTempImage=document.createElement("IMG")}(n),on(n,t,e),function(n){S(n)||(n[_]={backgroundImage:n.style.backgroundImage})}(n),function(n,t,e){var i=I(n,t.data_bg),o=I(n,t.data_bg_hidpi),r=a&&o?o:i;r&&(n.style.backgroundImage='url("'.concat(r,'")'),M(n).setAttribute(l,r),B(n,t,e))}(n,t,e),function(n,t,e){var i=I(n,t.data_bg_multi),o=I(n,t.data_bg_multi_hidpi),r=a&&o?o:i;r&&(n.style.backgroundImage=r,function(n,t,e){N(n,t.class_applied),A(n,b),e&&(t.unobserve_completed&&z(n,t),O(t.callback_applied,n,e))}(n,t,e))}(n,t,e)},rn=function(n,t,e){!function(n){return W.indexOf(n.tagName)>-1}(n)?an(n,t,e):function(n,t,e){on(n,t,e),function(n,t,e){var i=Q[n.tagName];i&&(i(n,t),B(n,t,e))}(n,t,e)}(n,t,e)},cn=function(n){n.removeAttribute(l),n.removeAttribute(s),n.removeAttribute(f)},un=function(n){D(n,(function(n){H(n,P)})),H(n,P)},ln={IMG:un,IFRAME:function(n){H(n,F)},VIDEO:function(n){V(n,(function(n){H(n,F)})),H(n,j),n.load()}},sn=function(n,t){(function(n){var t=ln[n.tagName];t?t(n):function(n){if(S(n)){var t=U(n);n.style.backgroundImage=t.backgroundImage}}(n)})(n),function(n,t){L(n)||w(n)||(C(n,t.class_entered),C(n,t.class_exited),C(n,t.class_applied),C(n,t.class_loading),C(n,t.class_loaded),C(n,t.class_error))}(n,t),k(n),\$(n)},fn=["IMG","IFRAME","VIDEO"],dn=function(n){return n.use_native&&"loading"in HTMLImageElement.prototype},_n=function(n,t,e){n.forEach((function(n){return function(n){return n.isIntersecting||n.intersectionRatio>0}(n)?function(n,t,e,i){var o=function(n){return x.indexOf(y(n))>=0}(n);A(n,"entered"),N(n,e.class_entered),C(n,e.class_exited),function(n,t,e){t.unobserve_entered&&z(n,e)}(n,e,i),O(e.callback_enter,n,t,i),o||rn(n,e,i)}(n.target,n,t,e):function(n,t,e,i){L(n)||(N(n,e.class_exited),function(n,t,e,i){e.cancel_on_exit&&function(n){return y(n)===g}(n)&&"IMG"===n.tagName&&(tn(n),function(n){D(n,(function(n){cn(n)})),cn(n)}(n),un(n),C(n,e.class_loading),R(i,-1),k(n),O(e.callback_cancel,n,t,i))}(n,t,e,i),O(e.callback_exit,n,t,i))}(n.target,n,t,e)}))},gn=function(n){return Array.prototype.slice.call(n)},vn=function(n){return n.container.querySelectorAll(n.elements_selector)},bn=function(n){return function(n){return y(n)===p}(n)},pn=function(n,t){return function(n){return gn(n).filter(L)}(n||vn(t))},hn=function(n,e){var o=c(n);this._settings=o,this.loadingCount=0,function(n,t){i&&!dn(n)&&(t._observer=new IntersectionObserver((function(e){_n(e,n,t)}),function(n){return{root:n.container===document?null:n.container,rootMargin:n.thresholds||n.threshold+"px"}}(n)))}(o,this),function(n,e){t&&window.addEventListener("online",(function(){!function(n,t){var e;(e=vn(n),gn(e).filter(bn)).forEach((function(t){C(t,n.class_error),k(t)})),t.update()}(n,e)}))}(o,this),this.update(e)};return hn.prototype={update:function(n){var t,o,a=this._settings,r=pn(n,a);T(this,r.length),!e&&i?dn(a)?function(n,t,e){n.forEach((function(n){-1!==fn.indexOf(n.tagName)&&function(n,t,e){n.setAttribute("loading","lazy"),on(n,t,e),function(n,t){var e=Q[n.tagName];e&&e(n,t)}(n,t),A(n,h)}(n,t,e)})),T(e,0)}(r,a,this):(o=r,function(n){n.disconnect()}(t=this._observer),function(n,t){t.forEach((function(t){n.observe(t)}))}(t,o)):this.loadAll(r)},destroy:function(){this._observer&&this._observer.disconnect(),vn(this._settings).forEach((function(n){\$(n)})),delete this._observer,delete this._settings,delete this.loadingCount,delete this.toLoadCount},loadAll:function(n){var t=this,e=this._settings;pn(n,e).forEach((function(n){z(n,t),rn(n,e,t)}))},restoreAll:function(){var n=this._settings;vn(n).forEach((function(t){sn(t,n)}))}},hn.load=function(n,t){var e=c(t);rn(n,e)},hn.resetStatus=function(n){k(n)},t&&function(n,t){if(t)if(t.length)for(var e,i=0;e=t[i];i+=1)u(n,e);else u(n,t)}(hn,window.lazyLoadOptions),hn})); (function () { var PenciLazy = new LazyLoad({ elements_selector: '.penci-lazy', data_bg: 'bgset', class_loading: 'lazyloading', class_entered: 'lazyloaded', class_loaded: 'pcloaded', unobserve_entered: true }); MutationObserver = window.MutationObserver || window.WebKitMutationObserver; var observer = new MutationObserver(function(mutations, observer) { PenciLazy.update(); }); observer.observe(document, { subtree: true, attributes: true }); })(); class SoledadLazyLoad{constructor(e){this.triggerEvents=e,this.eventOptions={passive:!0},this.userEventListener=this.triggerListener.bind(this),this.delayedScripts={normal:[],async:[],defer:[]},this.allJQueries=[]}_addUserInteractionListener(e){this.triggerEvents.forEach(t=>window.addEventListener(t,e.userEventListener,e.eventOptions))}_removeUserInteractionListener(e){this.triggerEvents.forEach(t=>window.removeEventListener(t,e.userEventListener,e.eventOptions))}triggerListener(){this._removeUserInteractionListener(this),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",this._loadEverythingNow.bind(this)):this._loadEverythingNow()}async _loadEverythingNow(){this._delayEventListeners(),this._delayJQueryReady(this),this._handleDocumentWrite(),this._registerAllDelayedScripts(),this._preloadAllScripts(),await this._loadScriptsFromList(this.delayedScripts.normal),await this._loadScriptsFromList(this.delayedScripts.defer),await this._loadScriptsFromList(this.delayedScripts.async),await this._triggerDOMContentLoaded(),await this._triggerWindowLoad(),window.dispatchEvent(new Event("soledadspeed-allScriptsLoaded"))}_registerAllDelayedScripts(){document.querySelectorAll("script[type=PenciLazyScript]").forEach(e=>{e.hasAttribute("src")?e.hasAttribute("async")&&!1!==e.async?this.delayedScripts.async.push(e):e.hasAttribute("defer")&&!1!==e.defer||"module"===e.getAttribute("data-pencilazy-type")?this.delayedScripts.defer.push(e):this.delayedScripts.normal.push(e):this.delayedScripts.normal.push(e)})}async _transformScript(e){return await this._requestAnimFrame(),new Promise(t=>{const n=document.createElement("script");let i;[...e.attributes].forEach(e=>{let t=e.nodeName;"type"!==t&&("data-pencilazy-type"===t&&(t="type",i=e.nodeValue),n.setAttribute(t,e.nodeValue))}),e.hasAttribute("src")?(n.addEventListener("load",t),n.addEventListener("error",t)):(n.text=e.text,t()),e.parentNode.replaceChild(n,e)})}async _loadScriptsFromList(e){const t=e.shift();return t?(await this._transformScript(t),this._loadScriptsFromList(e)):Promise.resolve()}_preloadAllScripts(){var e=document.createDocumentFragment();[...this.delayedScripts.normal,...this.delayedScripts.defer,...this.delayedScripts.async].forEach(t=>{const n=t.getAttribute("src");if(n){const t=document.createElement("link");t.href=n,t.rel="preload",t.as="script",e.appendChild(t)}}),document.head.appendChild(e)}_delayEventListeners(){let e={};function t(t,n){!function(t){function n(n){return e[t].eventsToRewrite.indexOf(n)>=0?"soledadspeed-"+n:n}e[t]||(e[t]={originalFunctions:{add:t.addEventListener,remove:t.removeEventListener},eventsToRewrite:[]},t.addEventListener=function(){arguments[0]=n(arguments[0]),e[t].originalFunctions.add.apply(t,arguments)},t.removeEventListener=function(){arguments[0]=n(arguments[0]),e[t].originalFunctions.remove.apply(t,arguments)})}(t),e[t].eventsToRewrite.push(n)}function n(e,t){let n=e[t];Object.defineProperty(e,t,{get:()=>n||function(){},set(i){e["soledad"+t]=n=i}})}t(document,"DOMContentLoaded"),t(window,"DOMContentLoaded"),t(window,"load"),t(window,"pageshow"),t(document,"readystatechange"),n(document,"onreadystatechange"),n(window,"onload"),n(window,"onpageshow")}_delayJQueryReady(e){let t=window.jQuery;Object.defineProperty(window,"jQuery",{get:()=>t,set(n){if(n&&n.fn&&!e.allJQueries.includes(n)){n.fn.ready=n.fn.init.prototype.ready=function(t){e.domReadyFired?t.bind(document)(n):document.addEventListener("soledadspeed-DOMContentLoaded",()=>t.bind(document)(n))};const t=n.fn.on;n.fn.on=n.fn.init.prototype.on=function(){if(this[0]===window){function e(e){return e.split(" ").map(e=>"load"===e||0===e.indexOf("load.")?"soledadspeed-jquery-load":e).join(" ")}"string"==typeof arguments[0]||arguments[0]instanceof String?arguments[0]=e(arguments[0]):"object"==typeof arguments[0]&&Object.keys(arguments[0]).forEach(t=>{delete Object.assign(arguments[0],{[e(t)]:arguments[0][t]})[t]})}return t.apply(this,arguments),this},e.allJQueries.push(n)}t=n}})}async _triggerDOMContentLoaded(){this.domReadyFired=!0,await this._requestAnimFrame(),document.dispatchEvent(new Event("soledadspeed-DOMContentLoaded")),await this._requestAnimFrame(),window.dispatchEvent(new Event("soledadspeed-DOMContentLoaded")),await this._requestAnimFrame(),document.dispatchEvent(new Event("soledadspeed-readystatechange")),await this._requestAnimFrame(),document.soledadonreadystatechange&&document.soledadonreadystatechange()}async _triggerWindowLoad(){await this._requestAnimFrame(),window.dispatchEvent(new Event("soledadspeed-load")),await this._requestAnimFrame(),window.soledadonload&&window.soledadonload(),await this._requestAnimFrame(),this.allJQueries.forEach(e=>e(window).trigger("soledadspeed-jquery-load")),window.dispatchEvent(new Event("soledadspeed-pageshow")),await this._requestAnimFrame(),window.soledadonpageshow&&window.soledadonpageshow()}_handleDocumentWrite(){const e=new Map;document.write=document.writeln=function(t){const n=document.currentScript,i=document.createRange(),a=n.parentElement;let d=e.get(n);void 0===d&&(d=n.nextSibling,e.set(n,d));const s=document.createDocumentFragment();i.setStart(s,0),s.appendChild(i.createContextualFragment(t)),a.insertBefore(s,d)}}async _requestAnimFrame(){return new Promise(e=>requestAnimationFrame(e))}static run(){const e=new SoledadLazyLoad(["keydown","mousemove","touchmove","touchstart","touchend","wheel"]);e._addUserInteractionListener(e)}}SoledadLazyLoad.run(); "use strict";window.penciLazyConfig={cssDelayType:"interact"},(()=>{const e=window.penciLazyConfig||{},t=!0;let n=[];const o={HTMLDocument:document.addEventListener.bind(document),Window:window.addEventListener.bind(window)},c={};let a,d=!1,r=!1,s=[],i=[];function l(t){(i=[...document.querySelectorAll("link[data-soledad_pagespeed-delay]")]).length&&function(t,n){t=t||"js";const c=n?"onload":e[t+"DelayType"]||"onload",a="js"===t?f:u;switch("js"===t&&(n||"onload"===c?y():g(y)),c){case"interact":let e=!1;const d=()=>{e||(e=!0,"js"===t?function(e){"loading"!==document.readyState?e():o.Window("DOMContentLoaded",()=>e())}(()=>setTimeout(a,2)):a())};["mousemove","mousedown","keydown","touchstart","wheel"].forEach(e=>{document.addEventListener(e,d,{passive:!0,once:!0})})}}("css",t)}function u(){i.forEach(e=>m(e))}function f(e){if(y(),!e){d=!0,a=document.readyState;let e="loading";Object.defineProperty(document,"readyState",{configurable:!0,get:()=>e,set:t=>e=t})}let t;const o=new Promise(e=>t=e),c=()=>{s.length?m(s.shift()).then(c):t()};c(),o.then(w).catch(e=>{console.error(e),w()}),setTimeout(()=>!n.length||w(),45e3)}function m(e){let t;const n=e.dataset.src,o=e=>new Promise(t=>{e.addEventListener("load",t),e.addEventListener("error",t)});if(n){const c=document.createElement("script");t=o(c),e.getAttributeNames().forEach(t=>{"src"===t||(c[t]=e[t])}),c.async=!1,c.src=n,e.parentNode.replaceChild(c,e)}const c=e.dataset.href;return c&&(t=o(e),e.href=c),t||Promise.resolve()}function h(e){try{e.cb.call(e.context,c[e.event],...e.args)}catch(e){console.error(e)}}function w(){if(r)return;t&&console.log("Firing Load Events",n),r=!0;const e=n.filter(e=>"readystatechange"===e.event);document.readyState="interactive",e.forEach(e=>h(e));for(const e of n)"DOMContentLoaded"===e.event&&h(e);for(const e of n)"load"===e.event&&h(e);n=[],r=!1,g(()=>{document.readyState="complete",setTimeout(()=>{e.forEach(e=>h(e))},2)})}function g(e){"complete"===(a||document.readyState)?e():o.Window("load",()=>e())}l(),document.addEventListener("pencilazy-load-css",()=>l(!0))})(); ```