Maybe…it isn't JavaScript?
A glimpse into my life with JavaScript SEO
Slide 3
Slide 3 text
First things first:
Is JavaScript the devil?
Slide 4
Slide 4 text
How do I know if it's a JavaScript problem?
Slide 5
Slide 5 text
How do I know if it's a JavaScript problem?
Slide 6
Slide 6 text
Okay, so what's going on here?
<- Browser
Google ->
Slide 7
Slide 7 text
Well well well…
Slide 8
Slide 8 text
Well well well…
Slide 9
Slide 9 text
So much for "Not a JavaScript problem", huh?
Slide 10
Slide 10 text
Wait…
Slide 11
Slide 11 text
Oh. Oh! Ouhh…
Slide 12
Slide 12 text
Okay but what about this?
Slide 13
Slide 13 text
But that's not there!!!
Slide 14
Slide 14 text
No content
Slide 15
Slide 15 text
Oh wait… every 10th or so time it is?!
Slide 16
Slide 16 text
WAT?
Slide 17
Slide 17 text
Oh wait…
Slide 18
Slide 18 text
Wait a minute…
Slide 19
Slide 19 text
Huh!
Slide 20
Slide 20 text
Oh wait… this must be Javascript!
Slide 21
Slide 21 text
Alright, what's going on here now?
Slide 22
Slide 22 text
Well, what do we have here?
Slide 23
Slide 23 text
Aha! JavaScript!1!11!
fetch(`https://api.martinschee.se/cheese/${id}`)
.then(res => res.json())
.then((cheese) => {
if (!cheese.exists) {
// status already sent, we cannot change :(
showErrorPage();
}
})
Slide 24
Slide 24 text
Okay fine… but how about we do better?
fetch(`https://api.martinschee.se/cheese/${id}`)
.then(res => res.json())
.then((cheese) => {
if (!cheese.exists) {
// redirect to page that gives a 404
window.location.href = '/not-found';
}
})