I asked this before and I have got several negative scores but this time I ask it more clear.
I have this structure on a website:
- Mainpage (All resources and scripts are in this page)
- All Other pages (HTML just contains elements of that specific page)
If user clicks on mainpage anchors to other pages, AJAX function that is embed to On click event
will run and URL address will change using Window.history.PushState
.
The problem is what we can do if user enters URL of other pages instead clicking on anchors? For example if user enters: http://example.com/pages/about then only elements of that page will load without resources and scripts of mainpage that is needed.
I think to a solution something like this:
- Detect if user enters URL instead clicking on anchors.(detect HTTP request)
- Load resources included in mainpage if it is a HTTP request.
Could this solution be in Client-side(javascript) way? I know a little PHP too.
Take a look at Cloudflare panel to see what i mean: https://www.cloudflare.com/a/overview