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
That said, it seems easy to make this backwards compatible: if the existing #blah syntax is a valid link, that should take precedence.
FWIW, I think there's way too much cynicism in this thread. My first reaction on seeing the title was "cool! I would use that!".
edit: Hmm, I may have misunderstood the compatibility issue.
That's indeed how it works. The majority of the compatibility concerns appear to be with apps that a using _custom_ parsing of the fragment to perform app-specific logic, which is a valid concern.
https://chrome.google.com/webstore/detail/display-anchors/po...
- How does this perform on existing pages - How does this feel from a user perspective - How can I write pages that user this
Specification-up-front is very theoretical in the absence of an implementation. IMHO, where it's (rarely) happened in practice, the specification is often unimplemented. The value of a specification is that it allows other browser vendors to add an interoperable implementation.
Again, I'd like to stress, this is in the very early-stage experimental phase. We aren't dropping a feature that'll break the existing web.
Edit: To clarify, "implementation" does not necessarily mean shipped to users.
Literally just today we got an article about Web Bluetooth on the front page of HN, a user-shipped capability in Chrome that is still in the Draft phase of standardization.[0]
Beyond that, we have the Web USB API, which is also in the draft phase, but is of course shipping to users in Chrome, on by default.[1]
Beyond that, we have HTML imports, which have been rejected from the standard but are still shipping to users in Chrome.[2]
I don't doubt your intentions, but if you think that Chrome is going to wait for standardization on this before it ships, you are not paying enough attention to the teams you're working with. And once Chrome ships a feature to users, the web standards body has basically two options: accept Google's vision of the standard wholesale, or change the standard and break websites that are already using Google's implementation.
I would be more confident and trusting of the process you describe if there was some kind of official commitment from the Chrome team that this feature will stay behind a browser flag until the standardization process is completely finished. But I think some of the reason you're getting immediate pushback to an extremely early draft of the spec is because developers don't trust Google not to ship this on-by-default once it reaches a WD stage.
[0]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Bluetoo...
[1]: https://developer.mozilla.org/en-US/docs/Web/API/USB
[2]: https://developer.mozilla.org/en-US/docs/Web/Web_Components/...
Microsoft did this many moons ago. People ended up defacing web sites like the New York Times and spreading proto fake news.
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.
I think the reason this sparked concern is because (by using fragments) this intrudes into a field that was previously under full author control.
I think clear guarantees about which aspects of a webpage are the responsibility of authors and which are under browser control are important - only going by real-world usage and assuming everything not directly used is free for the taking is not enough here.
E.g., I think there are failure modes for SPAs that are not easily found with a usage search. [1] Additionally, this would make it harder to know for new applications which kinds of fragment identifier are "safe" to use and which are not.
There seem to be some existing specs that deal with the same problem [2].
Maybe those could be a starting point for the feature to to forward without interop/responsibility problems?
It’s an exciting possibility to link more directly to resources. I hope it is implemented in such a way that all browsers can follow those links with parity in the future. If that is the case I have a few hundred thousand outlinks that could be refined for clarity.
To be clear, I agree that this format is exceedingly unlikely to collide with real fragments, but still seems like there is a safer approach.
To the fragment. Tt could, depending on how the app was written. Is there a framework or some common techniques that use this I could read-up on?
I work in analytics so I’ve seen things like UTM params get couched into the hash, breaking parsing, so at least it’s something to keep an eye out for.
You can claim to have high standards, but Google is trying to dictate the future of the web.
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"
Normally, url fragments were intended to be used by page authors, making clashes impossible (page author controls both page and anchor syntax). Google are breaking this contract, but argue that the fact that they're using parameter-style syntax should not clash with author usage, because using parameter-style syntax is "an abuse" of the feature.
To double check, does this means things like,
https://www.spa/#!/path/to/view
Can become https://www.spa/#!/path/to/view&targetText=percent%20encoded
The only part I don't get about the likelihood and this extension is how it interacts with these kind of hash routes.I haven't thought that much about the next part, but how do people feel about the following?
web+text://https://www.spa/#!/route/to/view#targetText=percent%20encoded
or something. Rather than extending URLs vertically, extend horizontally into a different protocol the URI of which can encode the syntax elegantly.Page authors are unlikely to use web+text: if it means cutting off old browsers from access.
Why not "##" as a new URL fragment, or add a "scrollto" to the link tag that the browser can use?
I guess those were discussed, is there an RFC?
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.
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.
Google's influence is massive, anyone wanting to build a profitable website needs to bend to their standards of performance and structure.
Normally this was a general push in the right direction for everyone. With how they've been handling AMP however, part of me wonders if they're not trying to build a feature moat around the web itself. Although misguided use of their power by individual product-managers is probably the less sinister, more likely reason.
I think it was called "Angular".
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.
It does require more coordination between the front and back-end though.
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.
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.
That way both could live together, if the page uses # in the fragment, just percent encode it.
At most this would break old bookmarks.
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.
In other words, even if you give an element "id='targetText=something'", this feature wouldn't break that.
If you do see a page that you think might break and you're on Chrome newer than 74.0.3706.0, try turning on chrome://flags#enable-text-fragment-anchor and giving it a try. If something looks out of place, that would be extremely useful data for us. File a bug either at
https://github.com/bokand/ScrollToTextFragment/issues
or
Also, this would require the "targetText" parameter to live peacefully alongside other parameters. (That in turn would require there were a standard definition of "parameter" inside the fragment at all)
E.g, if Chrome encounters an url with an existing fragment, it would somehow have to combine this with its own targetText parameter and hope the SPA still understands the combined fragment.
Hash isn’t used for query parameters.
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).
But not for query parameters per se, for app state stored in the query string (and bookmarkable).
https://stackoverflow.com/questions/15238391/hash-params-vs-...
https://store.steampowered.com/tags/en/Adventure/#p=3&tab=To...
Gmail used, others used it.
https://stackoverflow.com/questions/15238391/hash-params-vs-...
They could just be perfectly written (for their time), just legacy and not updated, is my distinction.
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?
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. 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). 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...