Created
August 1, 2024 06:32
-
-
Save JezDriver/0d08c46a5a5a70c839a660059c15c24f to your computer and use it in GitHub Desktop.
Check broken links using dev tools #js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Originally from Jhey: https://twitter.com/jh3yy/status/1793628022245150752 | |
| // I found from https://www.amitmerchant.com/little-devtools-snippet-to-check-broken-links-on-a-webpage/ | |
| // I added the a in the a[href] selector to avoid svg use elements | |
| // 1. Run this in dev tools | |
| // 2. Check the network tab (filter by Fetch/XHR) - see if there are any errors | |
| // 3. Repeat for each page | |
| $$('a[href]:not([href=""])').forEach(anchor => { | |
| console.info({ anchor, href: anchor.href }) | |
| fetch(anchor.href, { method: 'HEAD' }) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment