News for hackers. Stuff that matters.
Re:Show HN: I made a Cloudflare Worker that injects OpenGrap... by TIPSIO on Wednesday July 20, 2022 @12:25PM (#32168110)
Great job!

> Before you tell me to use Next.js, I know. But I think Cloudflare Workers are really cool!

It is really cool. I like to think sometimes there's no right way to do things so long it works for you.

For example, imagine an org/biz with a slow or busy dev team. Meta tags and SEO are constantly updating, pixels need to be dropped by marketing, stuff needs to be injected into the head, etc... This allows them to do so independently at a lower level.

Obviously the trade-off is this opens up to breaking things. Or, I'm not sure why they wouldn't use a Tag manager, but I am just saying out there this probably makes sense for someone.

> const body = text.replace(PLACEHOLDER, html);

I really need to learn Typescript... but I think this is where you update. This could break/timeout if the page is gigantic. A faster strategy would be to use their HTML Rewriter. [1]

[1] https://developers.cloudflare.com/workers/runtime-apis/html-...

Re:Show HN: I made a Cloudflare Worker that injects OpenGrap... by gepeake on Tuesday July 19, 2022 @11:12PM (#32160943)
Just FYI, the new wrangler supports direct typescript support including minification so webpack isn’t necessary anymore