-
Notifications
You must be signed in to change notification settings - Fork 520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid inserting section permalinks after DOM render, in DOM #44
Comments
Whatever we do, the stumptown-content shouldn't have to do anything to cater to this. // PSEUDO CODE
renderedHtml = renderedHtml.replace(/<\/h2>/g, '</h2> <a href="#anchor">Link</a>') |
Were you thinking maybe a utility type component for like |
To be honest, now I'm losing confidence in this one. We're about to massively change how the main document components are going to work. At this very moment, we're hardcoding how rendering is supposed to work. There's a React component called Now, in mdn/stumptown-content#107 we're changing all of this. Soon, the renderer just needs to loop over the JSON content from stumptown-content/packaged and use that Either way, starting here there are some outstanding issues with regards to how we should make those All in all, perhaps this is not a good issue to tackle at the moment. |
No worries, i understand. I'll check out some other issues. If there are areas in the BCD table that need ID set that way i can adjust. |
More of a note-to-self; but here's how npmjs.com does it. for example <h2>
<a id="user-content-using-the-node-cli" class="deep-link" href="#using-the-node-cli" aria-hidden="true" rel="nofollow">
<svg aria-hidden="true" class="deep-link-icon" height="16" version="1.1" viewbox="0 0 16 16" width="16">
<path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</svg>
</a>
Using the Node CLI
</h2> Here's how GitHub does it. for example <h2>
<a id="user-content-using-the-node-cli" class="anchor" aria-hidden="true" href="#using-the-node-cli">
<svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true">
<path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</svg>
</a>
Using the Node CLI
</h2> I guess, only by using inline SVGs can you style them. Note that this is server-side rendered HTML. Avoiding DOM mutations after the HTML has been loaded is great but is there really no way to do this with CSS? |
Let's go here instead: #1004 |
On https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video for example. The HTML sent from the server to the browser looks like this:
Then, a piece of (jQuery??) code kicks in after the .js has been downloaded, parsed and executed (after
document.onload
) that turns that into this:Let's not do that in stumptown.
Not only does it cause the page to "flicker" as the little section chain-icons suddenly appears. That makes the site feel "wobbly". It can also cause a re-paint (aka. recalculate style).
Note: Using Chrome Performance dev tools, with 6x CPU slowdown, I found 4!! blocks of "Recalculate style" in the first 3.5 seconds! It's very hard to exactly see how large the repaint is due to the added extra
<a>
tags.Either way, it should be avoidable. I.e. let's not modify the DOM shipped from the HTML from the server. At least not just to add section links.
I think (and hope) the permalink section can be done entirely with CSS.
The text was updated successfully, but these errors were encountered: