Lazy loading your images is a great way to increase performance and other Google Lighthouse metrics. Fortunately, there's now a simple native attribute you can add your your <img> tags that will lazy load them without any extra code. <img loading="la...
Markdown supported · ⌘↵ to post
Hello, I want to change the blogger permalink /p/test.html to /test-page/ and also canonical link and other links. but still can't rewrite the canonical and other links.
first code, with route settings like this:
www.domain.com/test-page*addEventListener("fetch", event => { return event.respondWith(fetch("domain.com/p/test.html")) })the second code, and the route settings are like this
*.domain.com/test-page*const OLD_URL = "domain.com/p/test.html"; const NEW_URL = "domain.com/test-page"; async function handleRequest(req) { const res = await fetch(req) return rewriter.transform(res) } class AttributeRewriter { constructor(attributeName) { this.attributeName = attributeName } element(element) { const attribute = element.getAttribute(this.attributeName) if (attribute) { element.setAttribute( this.attributeName, attribute.replace(OLD_URL, NEW_URL) ) } } } const rewriter = new HTMLRewriter() .on("link", new AttributeRewriter("href")) .on("meta", new AttributeRewriter("content")) addEventListener("fetch", event => { let url = event.request.url event.respondWith(handleRequest(url) .catch(err => new Response(err.toString(),{status:500}))) })