Reload page without <script> tags

ajax, html, javascript

Solution

Maybe not a better way, but an alternative to using javascript to do what you want:

You can write a (php) server-side script, use file_get_contents() to get the original page contents, use php to remove and replace javascript page contents (str_replace, substr_replace, preg_match) then call this php script in an iframe.

See my related answer for more detail: https://stackoverflow.com/a/17262334/888177

Problem

I need to render a page without executing it's JavaScript (however inject my own script), showing the user how the page would look from a bot's POV. So far I have thought of loading the page using ajax, removing all `<script></script>` tags from the loaded data, injecting my own `<script></script>` tags and replacing page html with the filtered data. Are there any better ways of achieving this?

Original source

Related problems