I've seen websites like YouTube and Gmail load fast. I know that Gmail is a Single Page App but YouTube is not, Is there a way to make a website that is not a SPA that can load this fast?
NOTE: I am using a static site
This post is pretty old now. I understand you need to use "hashtag urls" instead of direct ones. Direct ones can be shown as the address with history.pushState
.
MDN:
https://developer.mozilla.org/en-US/docs/Web/API/History/pushState
https://developer.mozilla.org/en-US/docs/Glossary/SPA
Example of a SPA App
<!DOCTYPE html>
<html lang="en">
<head>
<script>
if (document.location.href == 'https://example.com/#page'){
history.pushState('', '', "https://example.com/page")
document.querySelector("body").
}
// use 301 redirects to make sure the /page url (without hashtag) goes to the one with a hashtag.
</script>
</head>
<body>
</body>
</html>