Skip to content

Commit

Permalink
chore: use prerender and dns-prefetch
Browse files Browse the repository at this point in the history
Signed-off-by: Logan McAnsh <[email protected]>
  • Loading branch information
mcansh committed Jan 13, 2023
1 parent f75bd1e commit 99d2559
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions integration/prefetch-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ test.describe("prefetch=intent (hover)", () => {
`#nav link[rel='prefetch'][as='document'][href='${EXTERNAL_URL}']`,
{ state: "attached" }
);
expect(await page.locator("#nav link").count()).toBe(1);
expect(await page.locator("#nav link").count()).toBe(2);
});

test("removes prefetch tags after navigating to/from the page", async ({
Expand All @@ -221,7 +221,7 @@ test.describe("prefetch=intent (hover)", () => {
// Links added on hover (external)
await page.hover(`a[href='${EXTERNAL_URL}']`);
await page.waitForSelector("#nav link", { state: "attached" });
expect(await page.locator("#nav link").count()).toBe(1);
expect(await page.locator("#nav link").count()).toBe(2);

// Links removed upon navigating to the page
await page.click("a[href='/with-loader']");
Expand Down Expand Up @@ -290,6 +290,6 @@ test.describe("prefetch=intent (focus)", () => {
`#nav link[rel='prefetch'][as='document'][href='${EXTERNAL_URL}']`,
{ state: "attached" }
);
expect(await page.locator("#nav link").count()).toBe(1);
expect(await page.locator("#nav link").count()).toBe(2);
});
});
5 changes: 4 additions & 1 deletion packages/remix-react/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,10 @@ let Link = React.forwardRef<HTMLAnchorElement, RemixLinkProps>(
{children}
</a>
{shouldPrefetch ? (
<link key={href} rel="prefetch" as="document" href={to} />
<>
<link rel="prerender" href={to} />
<link rel="dns-prefetch" href={to} />
</>
) : null}
</>
);
Expand Down

0 comments on commit 99d2559

Please sign in to comment.