10 ms·
Technical question, apart from the (valid IMO) political arguments: Google's idea to implement this is to append the text fragment to the URL in a "#targetText"
by xg15 8y ago
Technical question, apart from the (valid IMO) political arguments: Google's idea to implement this is to append the text fragment to the URL in a "#targetText" pseudo-query-argument in the URL fragment part. This sounds like it would extremely easily break existing web pages who use the fragment part for their own state.
In the blog post, there doesn't seem to be anything addressing this (or even just specifying how Chrome would combine the "targetText" fragment with an already existing fragment part)
Did they spend any thought on this?
Edit: Oh, right, the readme answers this:
> Web pages could potentially be using the fragment to store parameters, e.g. http://example.com/#name=test http://example.com/#name=test. If sites are already using targetText in the URL fragment for their own purposes, this feature could break those sites.
> We expect this usage to be exceedingly rare. It's an abuse of the purpose of URL fragments and page arguments are typically encoded using the '?' character (e.g. http://example.com?name=test http://example.com?name=test). Still, we may run an experiment to see if targetText is available enough to use as a reserved token.
We'll just completely change the commonly understand processing model of fragment identifiers, but it'll be fine since we don't think anyone is using them anyway...
No further questions...
- sascha_sl 8y agoHmm, who provided the first popular JS framework that used fragments for navigation again? I think it was called "Angular".
- chrismorgan 8y agoGmail was probably the first very-widely-used app that used the fragment for navigation, and Google drove the whole #! thing. That technique is now considered obsolete, with the History API (history.pushState and all that lot) having supplanted it. IE9 is the most popular browser currently in use that doesn’t support it; there are still definitely some systems out there that will use the History API if it’s available, or fall back to using the hash if it’s not, but I find that using the hash for navigation in deployed apps is surprisingly dead, given that it’s shy of six and a half years since IE10 came out, and Firefox and Chrome only had a year and two’s lead (and Chrome’s implementation especially was unreliable for quite some time). Using the hash for navigation is still very common in development workflows. But that can be ignored for a feature like this.
- blattimwind 8y agopushState is bad for many use cases because it completely breaks linking.
- roywiggins 8y agoIt doesn't have to, if you also provide routes on the backend so that pushState URLs actually resolve to a real URL that serves the same content. Or just provide a wildcard route and use JS to detect the URL like you would with hash-based navigation. It does require more coordination between the front and back-end though.
- blattimwind 8y agoI meant using pushState using the state object for something other than caching. If I click on "About us" and this results in pushState({page:"about-us"}, "", "#") then linking just doesn't work any more. It's a regression back to the days of Flash.
- roywiggins 8y agoAh, gotcha. Yes, that's a truly awful way to use it.
- Bjartr 8y agoYou can go back even further. GWT (formerly Google Web Toolkit) uses the fragment to store navigation tokens. I actively maintain a GWT SPA in my day job.
- lucideer 8y ago> It's an abuse of the purpose of URL fragments So what they're saying is, they expect a clash of their abuse of URL fragments with others' abuse of URL fragmentsto be rare because... The arrogance here is astounding: "It's OK for us to use this, because others shouldn't be using it"
- jypepin 8y agoAren't url fragment originally used for page position already? Like url.com/#title would scroll to the page the div with id "title"? In that case I don't feel like using url fragment for a word position is so much breaking it, it keeps the use of url fragment for info about page position, right?
- coldtea 8y ago>Aren't url fragment originally used for page position already? Like url.com/#title would scroll to the page the div with id "title"? That was the pre-SPA, traditional role of anchors... If you did any html between 1995-6 and 2005, you'd use it for that. Then, with AJAX/SPAs, # was used for state (pre-history API) -- and I'd assume many webpages are still left at that use.
- tyingq 8y agoOf course, page anchors are still in wide use, and not just on old pages. https://github.com/facebook/react/blob/master/README.md#installation https://github.com/facebook/react/blob/master/README.md#inst...
- reaperducer 8y agoVery wide use. I just finished a large healthcare web site that uses page anchors. Page anchors are recommended by one of the (many) federal web accessibility guidelines. This is so that people with limited motion or poor motor control, or visual impairments don’t have to scroll to find what they’re looking for on a page. It’s also how the “Skip to content” links work, which is Accessibility 101. Sorry, I’m not at work or on a computer so I can’t link to a reference.
- airza 8y agoGood lord, I see pages that would break from this constantly...
- supermatt 8y agoyou constantly see pages with #targetText=blah fragments?
- rolae 8y agoI think he means it the other way around. You have a Single page application with routing based on #someRoute, then someone tries to share some link with the #targetText=... which will lead to an invalid route. Or am I missunderstanding something?
- prepend 8y agoYou’re thinking of ?targetText= or &targetText= Hash isn’t used for query parameters.
- aepiepaey 8y agoNot for query parameters sent to the remote server, but there are definitely pages/applications that store state in the hash. For example, look at the URLs used by mega.nz, or any encrypted pastebin (they store the decryption key in the hash so it's not sent to the server).
- bryanrasmussen 8y agolots of older or poorly written SPAs use the hash exactly in this way. I guess their fault for being poorly written, like those people who allowed GET requests to /deleteaccount based on the theory that you had to be logged in with a browser for it to ever happen and not considering that google would make an extension that did all get requests on a page on entry.
- coldtea 8y ago
- pfortuny 8y agoWe shall stop using the turning lights (blinkers)... It is an abuse but anyway, novody uses them.
- fxfan 8y ago> We'll just completely change the commonly understand processing model of fragment identifiers, but it'll be fine since we don't think anyone is using them anyway... That's not true. Truth is: > We'll just completely change the commonly understand processing model of fragment identifiers, it may not be fine, but can you really stop us?
- prepend 8y agoIt should only cause a problem for pages using “targetText” as an anchor or id where someone would link to “page#targetText” I would expect that it’s possible for both to work since Chrome’s hack requires the equal sign and its parameters. So with no equal, works as spec. With equal works with hack (that will likely make it into spec). Even when a page has the targetText anchor and receives the text link param, I think the desired user behavior is to link to the text, not the anchor.
- bokan 8y agoThe proposal, as currently stated, is to use fragment id processing first. If that fails to find a target, fallback to text matching. In other words, even if you give an element "id='targetText=something'", this feature wouldn't break that.
- dspillett 8y agoWhile it does smack a little of the arrogance of a big player, they are using the fragment part for more-or-less what it used to be used for (navigating to a specific location on a page), and if you use something in a way it isn't intended (using a navigation aid for state management) perhaps you should expect certain things to break at some point when combined with other hacks of the same feature. It is important to note that this won't break your site/app in the normal use case. People using your work will continue to do so uninhibited unless/until they wish to use this new feature in Chrome.
- hiccuphippo 8y agoCouldn't they put this in a second fragment? #pageNavigation=home##targetText=foo That way both could live together, if the page uses # in the fragment, just percent encode it. At most this would break old bookmarks.
- darkerside 8y agoWouldn't it be valid to anchor the link to a div with an 'id' of targetText? I fail to see how that's in any way an abuse of URL fragments.
- bokan 8y agoFeature author here. I'd like to first clarify that this is still in the super-early stage of development; none of this is shipped or finalized yet. The feature hasn't even requested approval to ship at which point these kinds of issues would be brought up. We take web-compat very seriously. If this breaks even a small percentage of pages, it won't ship. Part of the shipping process is ensuring we have at least a draft spec (W3C,WHATWG) at least some support from other vendors. Sorry, the explainer text came off more dismissive than I intended. I wanted to get something implemented so we could start experimenting and see how this would work in the wild. #targetText= is a a first attempt at syntax, any criticisms or data on how this might break would be appreciated. From my (limited) understanding of how fragments are used like this today, the way this would break a page is if the page itself was using "targetText=..." and parsing the result. This is something we can and will measure and see if we have a naming collision. For pages that use a "#var=name" type fragment, we could append "&targetText=...". I'm not tied to any particular syntax here so if I'm missing why this is a monumentally bad idea, please file a bug on the GitHub repo: https://github.com/bokand/ScrollToTextFragment/issues https://github.com/bokand/ScrollToTextFragment/issues
- ecshafer 8y agoWhy is this not being pushed to become part of the web spec first? That seems more reasonable than pushing a feature with the possibility of breaking pages that are spec compliant.
- ehnto 8y agoThis is my only gripe. Please work with a spec first, so that the feature flows naturally through to other vendors. Especially because it's changing the way URLs work. You're going to get people generating millions of these links around the web. That's a long term legacy of hyperlinks generated by the citizens of the web. Although the fallback is obviously pretty harmless, what about a future feature? If this doesn't work out, but some other feature down the line does, suddenly thousands of these links start working in weird ways. Or worse, the feature doesn't happen at all, because of the legacy of broken links. I know that's pessimistic, but URLs are the foundation of the web, changing how they work should be funneled through the spec.
- huhtenberg 8y ago> It's an abuse of the purpose of URL fragments Would you just look at who's preaching... If it ain't the same Google that all but standardized the use of #! contraption in the pre-HTML5 days - "you don't use, we don't crawl it" kinda thing. This is an abuse alright, but a better choice of wording might've been appropriate.