rsnext/packages/next/client
Bruno Crosier 48dd9954d8
Add fallback for <Image /> component when JavaScript is disabled in browser (#19052)
The current `<Image />` component does not fallback gracefully when JavaScript is disabled in the client / browser.

You can test this with the [official Next/Image example](https://csb-4k0kr-p8ya8f304.vercel.app/), by disabling JavaScript in the browser's DevTools. Video demo: https://streamable.com/frkvw9

This PR aims to fix this behaviour by using `<noscript></noscript>` tags to conditionally display a standard `<img>` element using the `props` passed to `<Image />` when JavaScript is disabled.

For browser sessions where JavaScript is enabled, this will not cause an increase in network requests, so there should be no downside.

One area where this PR is a bit "hacky" is that it uses a negative `margin-top` to counteract `sizerStyle.paddingTop`. From what I can tell, `sizerStyle.paddingTop` is generated on the server side, where we can not know ahead of time whether JavaScript is enabled in the browser - hence why I've opted for this solution. 

Fixes #19223
Fixes #21214
2021-03-23 19:25:00 +00:00
..
dev Remove unnecessary unfetch polyfill for dev (#20589) 2020-12-29 21:01:42 +00:00
portal Revert "Revert "[a11y] Route Announcements"" (#23086) 2021-03-15 20:18:11 +00:00
experimental-script.tsx Experimental script loader changes (#22038) 2021-03-02 19:17:33 +00:00
head-manager.ts refactor(client): add return types (#20728) 2021-01-05 15:11:37 +00:00
image.tsx Add fallback for <Image /> component when JavaScript is disabled in browser (#19052) 2021-03-23 19:25:00 +00:00
index.tsx Revert "Revert "[a11y] Route Announcements"" (#23086) 2021-03-15 20:18:11 +00:00
link.tsx Revert "Revert "[a11y] Route Announcements"" (#23086) 2021-03-15 20:18:11 +00:00
next-dev.js Remove the static optimization indicator (#18629) 2020-11-02 09:27:36 +01:00
next.js Shave a few bytes off the bootstrap code (#14457) 2020-06-22 17:50:17 +00:00
normalize-trailing-slash.ts fix basepath trailing slash (#15200) 2020-07-15 23:53:31 +00:00
page-loader.ts Ensure i18n index prefetch is correct with trailingSlash (#22746) 2021-03-14 12:58:34 +00:00
performance-relayer.ts refactor(client): add return types (#20728) 2021-01-05 15:11:37 +00:00
polyfills.js polyfills 2020-03-30 16:26:25 -04:00
request-idle-callback.ts fix(link): cancel idle callback on unmount (#22072) 2021-02-11 13:51:41 -05:00
route-announcer.tsx Revert "Revert "[a11y] Route Announcements"" (#23086) 2021-03-15 20:18:11 +00:00
route-loader.ts Fix idleTimeout error being thrown in route loader (#22775) 2021-03-05 16:32:00 +00:00
router.ts Add isPreview field to router (#21638) 2021-02-18 18:34:33 +00:00
use-intersection.tsx fix(link): cancel idle callback on unmount (#22072) 2021-02-11 13:51:41 -05:00
with-router.tsx refactor(client): add return types (#20728) 2021-01-05 15:11:37 +00:00