{"id":4049,"date":"2015-06-08T20:02:30","date_gmt":"2015-06-08T20:02:30","guid":{"rendered":"https:\/\/saucal.com\/?p=4049"},"modified":"2025-04-02T20:01:05","modified_gmt":"2025-04-02T20:01:05","slug":"problemas-de-funcionamiento-de-la-api-historia-resueltos","status":"publish","type":"post","link":"https:\/\/saucal.com\/es\/blog\/problemas-de-funcionamiento-de-la-api-historia-resueltos\/","title":{"rendered":"Los problemas de trabajar con History API y c\u00f3mo los solucionamos"},"content":{"rendered":"<p>\u00bfAlguna vez has trabajado con la History API para construir tus aplicaciones? \u00bfNo? \u00a1Pues deber\u00edas intentarlo, es incre\u00edble!<\/p>\n<p>\u00bfNo me crees? \u00bfPiensas que es una mierda? Pues probablemente sea porque te has encontrado con alguno de sus muchos problemas:<\/p>\n<ul>\n<li class=\"translation-block\">En algunos casos, un evento popstate se activa al cargar la p\u00e1gina sin una raz\u00f3n aparente. Esto ocurre cuando actualizas una p\u00e1gina que anteriormente ten\u00eda un estado configurado. La mayor\u00eda de las veces no necesitas esto, ya que puedes verificar el <b>window.history.state<\/b> desde JS al cargar la p\u00e1gina si necesitas hacer algo con \u00e9l. Se siente m\u00e1s natural que un evento popstate solo se active cuando el usuario presiona los botones de retroceso o avance, \u00bfverdad?<\/li>\n<li class=\"translation-block\">\u00bfPor qu\u00e9 incluir el par\u00e1metro <b>title<\/b> en los m\u00e9todos <b><i>pushState<\/i><\/b> y <b><i>replaceState<\/i><\/b> si los navegadores ni siquiera lo est\u00e1n implementando? No es ciencia espacial cambiar el par\u00e1metro <b>document.title<\/b>. \u00a1Vamos, Mozilla y Google! Microsoft, sabemos que lo intentas con todas tus fuerzas \u2013 \u00a1solo eliminen IE de una vez!<\/li>\n<li class=\"translation-block\">Google Analytics todav\u00eda no se lleva bien con la History API, pero en este caso es comprensible. No todos los eventos <b><i>pushState<\/i><\/b> o <b><i>popState<\/i><\/b> est\u00e1n destinados a activar una respuesta de Analytics.<\/li>\n<\/ul>\n<p>Despu\u00e9s de luchar con estos problemas durante un tiempo, he creado una peque\u00f1a biblioteca JS que proporciona casi la misma interfaz que el objeto historia nativo, pero llena los vac\u00edos mencionados anteriormente.<\/p>\n<p>Est\u00e1 incluido en nuestro framework de c\u00f3digo abierto, Ignite WP. Echa un vistazo a la fuente <a href=\"https:\/\/github.com\/saucal\/ignitewp\/blob\/master\/wp-content\/plugins\/ignite-wp\/inc\/history-api-helper\/js\/history-api-helper.js\" target=\"_blank\" rel=\"noopener\">aqu\u00ed<\/a> y documentaci\u00f3n <a href=\"https:\/\/github.com\/saucal\/ignitewp\/wiki\/History-API-Helper\" target=\"_blank\" rel=\"noopener\">aqu\u00ed<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Have you ever worked with the History API to build your apps? No? Well you should try it &#8211; it\u2019s awesome! You don\u2019t believe me? You think it sucks? Well, that\u2019s probably because you\u2019ve encountered some of the many problems with it: In some cases, a popstate event is triggered at pageload for no apparent [&hellip;]<\/p>\n","protected":false},"author":20,"featured_media":24563,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[76],"tags":[],"class_list":["post-4049","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-woocommerce-tutorials"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.6 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>The problems of working with History API, and how we solved them - Saucal<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/saucal.com\/es\/blog\/problemas-de-funcionamiento-de-la-api-historia-resueltos\/\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The problems of working with History API, and how we solved them - Saucal\" \/>\n<meta property=\"og:description\" content=\"Have you ever worked with the History API to build your apps? No? Well you should try it &#8211; it\u2019s awesome! You don\u2019t believe me? You think it sucks? Well, that\u2019s probably because you\u2019ve encountered some of the many problems with it: In some cases, a popstate event is triggered at pageload for no apparent [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/saucal.com\/es\/blog\/problemas-de-funcionamiento-de-la-api-historia-resueltos\/\" \/>\n<meta property=\"og:site_name\" content=\"Saucal\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Saucal\/\" \/>\n<meta property=\"article:published_time\" content=\"2015-06-08T20:02:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-02T20:01:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/saucal.com\/wp-content\/uploads\/sites\/2\/2024\/10\/Page-promo-image-HP.png?fit=1200%2C630\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Matias Saggiorato\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Saucal\" \/>\n<meta name=\"twitter:site\" content=\"@Saucal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Matias Saggiorato\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/saucal.com\\\/blog\\\/problems-working-history-api-solved\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/saucal.com\\\/blog\\\/problems-working-history-api-solved\\\/\"},\"author\":{\"name\":\"Matias Saggiorato\",\"@id\":\"https:\\\/\\\/saucal.com\\\/#\\\/schema\\\/person\\\/ceaa8ef5d85b0cb421c3814b03b20b71\"},\"headline\":\"The problems of working with History API, and how we solved them\",\"datePublished\":\"2015-06-08T20:02:30+00:00\",\"dateModified\":\"2025-04-02T20:01:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/saucal.com\\\/blog\\\/problems-working-history-api-solved\\\/\"},\"wordCount\":264,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/saucal.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/saucal.com\\\/blog\\\/problems-working-history-api-solved\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/saucal.com\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2019\\\/10\\\/rectangle-placeholder.svg\",\"articleSection\":[\"WooCommerce Tutorials\"],\"inLanguage\":\"es-ES\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/saucal.com\\\/blog\\\/problems-working-history-api-solved\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/saucal.com\\\/blog\\\/problems-working-history-api-solved\\\/\",\"url\":\"https:\\\/\\\/saucal.com\\\/blog\\\/problems-working-history-api-solved\\\/\",\"name\":\"The problems of working with History API, and how we solved them - Saucal\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/saucal.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/saucal.com\\\/blog\\\/problems-working-history-api-solved\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/saucal.com\\\/blog\\\/problems-working-history-api-solved\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/saucal.com\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2019\\\/10\\\/rectangle-placeholder.svg\",\"datePublished\":\"2015-06-08T20:02:30+00:00\",\"dateModified\":\"2025-04-02T20:01:05+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/saucal.com\\\/blog\\\/problems-working-history-api-solved\\\/#breadcrumb\"},\"inLanguage\":\"es-ES\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/saucal.com\\\/blog\\\/problems-working-history-api-solved\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"es-ES\",\"@id\":\"https:\\\/\\\/saucal.com\\\/blog\\\/problems-working-history-api-solved\\\/#primaryimage\",\"url\":\"https:\\\/\\\/saucal.com\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2019\\\/10\\\/rectangle-placeholder.svg\",\"contentUrl\":\"https:\\\/\\\/saucal.com\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2019\\\/10\\\/rectangle-placeholder.svg\",\"width\":380,\"height\":230},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/saucal.com\\\/blog\\\/problems-working-history-api-solved\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/saucal.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The problems of working with History API, and how we solved them\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/saucal.com\\\/#website\",\"url\":\"https:\\\/\\\/saucal.com\\\/\",\"name\":\"Saucal\",\"description\":\"Your eCommerce Architechs\",\"publisher\":{\"@id\":\"https:\\\/\\\/saucal.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/saucal.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es-ES\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/saucal.com\\\/#organization\",\"name\":\"Saucal\",\"url\":\"https:\\\/\\\/saucal.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es-ES\",\"@id\":\"https:\\\/\\\/saucal.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/saucal.com\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/10\\\/saucal-logo.svg\",\"contentUrl\":\"https:\\\/\\\/saucal.com\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/10\\\/saucal-logo.svg\",\"width\":75,\"height\":75,\"caption\":\"Saucal\"},\"image\":{\"@id\":\"https:\\\/\\\/saucal.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/Saucal\\\/\",\"https:\\\/\\\/x.com\\\/Saucal\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/1984234\\\/\",\"https:\\\/\\\/www.instagram.com\\\/saucal\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/saucal.com\\\/#\\\/schema\\\/person\\\/ceaa8ef5d85b0cb421c3814b03b20b71\",\"name\":\"Matias Saggiorato\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es-ES\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5583166a0a76d978bc38014c9d4f068b7c6f3eea75fb2fc3994d99ec67eca7?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5583166a0a76d978bc38014c9d4f068b7c6f3eea75fb2fc3994d99ec67eca7?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5583166a0a76d978bc38014c9d4f068b7c6f3eea75fb2fc3994d99ec67eca7?s=96&d=mm&r=g\",\"caption\":\"Matias Saggiorato\"},\"description\":\"Known as \\\"The Obsessive Planner,\\\" is the CTO at Saucal. Born in Bell Ville, Argentina, he is fluent in both Spanish and English and proficient in languages like CSS, PHP, JavaScript, HTML5, and C#.\",\"url\":\"https:\\\/\\\/saucal.com\\\/es\\\/blog\\\/author\\\/matias\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Los problemas de trabajar con la API de Historia, y c\u00f3mo los resolvimos - Saucal","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/saucal.com\/es\/blog\/problemas-de-funcionamiento-de-la-api-historia-resueltos\/","og_locale":"es_ES","og_type":"article","og_title":"The problems of working with History API, and how we solved them - Saucal","og_description":"Have you ever worked with the History API to build your apps? No? Well you should try it &#8211; it\u2019s awesome! You don\u2019t believe me? You think it sucks? Well, that\u2019s probably because you\u2019ve encountered some of the many problems with it: In some cases, a popstate event is triggered at pageload for no apparent [&hellip;]","og_url":"https:\/\/saucal.com\/es\/blog\/problemas-de-funcionamiento-de-la-api-historia-resueltos\/","og_site_name":"Saucal","article_publisher":"https:\/\/www.facebook.com\/Saucal\/","article_published_time":"2015-06-08T20:02:30+00:00","article_modified_time":"2025-04-02T20:01:05+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/saucal.com\/wp-content\/uploads\/sites\/2\/2024\/10\/Page-promo-image-HP.png?fit=1200%2C630","type":"image\/png"}],"author":"Matias Saggiorato","twitter_card":"summary_large_image","twitter_creator":"@Saucal","twitter_site":"@Saucal","twitter_misc":{"Written by":"Matias Saggiorato","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/saucal.com\/blog\/problems-working-history-api-solved\/#article","isPartOf":{"@id":"https:\/\/saucal.com\/blog\/problems-working-history-api-solved\/"},"author":{"name":"Matias Saggiorato","@id":"https:\/\/saucal.com\/#\/schema\/person\/ceaa8ef5d85b0cb421c3814b03b20b71"},"headline":"The problems of working with History API, and how we solved them","datePublished":"2015-06-08T20:02:30+00:00","dateModified":"2025-04-02T20:01:05+00:00","mainEntityOfPage":{"@id":"https:\/\/saucal.com\/blog\/problems-working-history-api-solved\/"},"wordCount":264,"commentCount":0,"publisher":{"@id":"https:\/\/saucal.com\/#organization"},"image":{"@id":"https:\/\/saucal.com\/blog\/problems-working-history-api-solved\/#primaryimage"},"thumbnailUrl":"https:\/\/saucal.com\/wp-content\/uploads\/sites\/2\/2019\/10\/rectangle-placeholder.svg","articleSection":["WooCommerce Tutorials"],"inLanguage":"es-ES","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/saucal.com\/blog\/problems-working-history-api-solved\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/saucal.com\/blog\/problems-working-history-api-solved\/","url":"https:\/\/saucal.com\/blog\/problems-working-history-api-solved\/","name":"Los problemas de trabajar con la API de Historia, y c\u00f3mo los resolvimos - Saucal","isPartOf":{"@id":"https:\/\/saucal.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/saucal.com\/blog\/problems-working-history-api-solved\/#primaryimage"},"image":{"@id":"https:\/\/saucal.com\/blog\/problems-working-history-api-solved\/#primaryimage"},"thumbnailUrl":"https:\/\/saucal.com\/wp-content\/uploads\/sites\/2\/2019\/10\/rectangle-placeholder.svg","datePublished":"2015-06-08T20:02:30+00:00","dateModified":"2025-04-02T20:01:05+00:00","breadcrumb":{"@id":"https:\/\/saucal.com\/blog\/problems-working-history-api-solved\/#breadcrumb"},"inLanguage":"es-ES","potentialAction":[{"@type":"ReadAction","target":["https:\/\/saucal.com\/blog\/problems-working-history-api-solved\/"]}]},{"@type":"ImageObject","inLanguage":"es-ES","@id":"https:\/\/saucal.com\/blog\/problems-working-history-api-solved\/#primaryimage","url":"https:\/\/saucal.com\/wp-content\/uploads\/sites\/2\/2019\/10\/rectangle-placeholder.svg","contentUrl":"https:\/\/saucal.com\/wp-content\/uploads\/sites\/2\/2019\/10\/rectangle-placeholder.svg","width":380,"height":230},{"@type":"BreadcrumbList","@id":"https:\/\/saucal.com\/blog\/problems-working-history-api-solved\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/saucal.com\/"},{"@type":"ListItem","position":2,"name":"The problems of working with History API, and how we solved them"}]},{"@type":"WebSite","@id":"https:\/\/saucal.com\/#website","url":"https:\/\/saucal.com\/","name":"Saucal","description":"Sus arquitectos de comercio electr\u00f3nico","publisher":{"@id":"https:\/\/saucal.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/saucal.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es-ES"},{"@type":"Organization","@id":"https:\/\/saucal.com\/#organization","name":"Saucal","url":"https:\/\/saucal.com\/","logo":{"@type":"ImageObject","inLanguage":"es-ES","@id":"https:\/\/saucal.com\/#\/schema\/logo\/image\/","url":"https:\/\/saucal.com\/wp-content\/uploads\/sites\/2\/2024\/10\/saucal-logo.svg","contentUrl":"https:\/\/saucal.com\/wp-content\/uploads\/sites\/2\/2024\/10\/saucal-logo.svg","width":75,"height":75,"caption":"Saucal"},"image":{"@id":"https:\/\/saucal.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Saucal\/","https:\/\/x.com\/Saucal","https:\/\/www.linkedin.com\/company\/1984234\/","https:\/\/www.instagram.com\/saucal\/"]},{"@type":"Person","@id":"https:\/\/saucal.com\/#\/schema\/person\/ceaa8ef5d85b0cb421c3814b03b20b71","name":"Mat\u00edas Saggiorato","image":{"@type":"ImageObject","inLanguage":"es-ES","@id":"https:\/\/secure.gravatar.com\/avatar\/8e5583166a0a76d978bc38014c9d4f068b7c6f3eea75fb2fc3994d99ec67eca7?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/8e5583166a0a76d978bc38014c9d4f068b7c6f3eea75fb2fc3994d99ec67eca7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8e5583166a0a76d978bc38014c9d4f068b7c6f3eea75fb2fc3994d99ec67eca7?s=96&d=mm&r=g","caption":"Matias Saggiorato"},"description":"Conocido como \"El planificador obsesivo\", es el CTO de Saucal. Nacido en Bell Ville, Argentina, habla espa\u00f1ol e ingl\u00e9s con fluidez y domina lenguajes como CSS, PHP, JavaScript, HTML5 y C#.","url":"https:\/\/saucal.com\/es\/blog\/author\/matias\/"}]}},"jetpack_featured_media_url":"https:\/\/saucal.com\/wp-content\/uploads\/sites\/2\/2019\/10\/rectangle-placeholder.svg","get_sub_heading":"","get_post_reading_time":"\t\t<div id=\"reading_4049\" class=\"post-reading-time\">\n\t\t\t<p class=\"post-reading-time__text\">2 Min Read<\/p>\n\t\t<\/div>\n\t\t","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/saucal.com\/es\/wp-json\/wp\/v2\/posts\/4049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/saucal.com\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/saucal.com\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/saucal.com\/es\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/saucal.com\/es\/wp-json\/wp\/v2\/comments?post=4049"}],"version-history":[{"count":1,"href":"https:\/\/saucal.com\/es\/wp-json\/wp\/v2\/posts\/4049\/revisions"}],"predecessor-version":[{"id":9502,"href":"https:\/\/saucal.com\/es\/wp-json\/wp\/v2\/posts\/4049\/revisions\/9502"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/saucal.com\/es\/wp-json\/wp\/v2\/media\/24563"}],"wp:attachment":[{"href":"https:\/\/saucal.com\/es\/wp-json\/wp\/v2\/media?parent=4049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/saucal.com\/es\/wp-json\/wp\/v2\/categories?post=4049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/saucal.com\/es\/wp-json\/wp\/v2\/tags?post=4049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}