Reputation: 62896
I have a page with a lots of javascript. However, the page once rendered remains static, there are no moving things or special effects, etc... It should be possible to render the same HTML without any javascript at all using only the plain HTML and CSS. This is exactly what I want - I would like to get a no javascript version of the particular page. Surely, I do not expect any dynamic behavior, so I am OK if buttons are dead, for example. I just want them rendered.
Now, I do not want an image. It needs to be an HTML with CSS, may be embedded with the HTML, which is fine too.
How can I do it?
EDIT
I am sorry, but I must have not been clear. My web site works with javascript and will not work without it. I do not want to check if it works without, I know it will not and I really do not care about it. This is not what I am asking. I am asking about a specific page, which I want to grab as pure HTML + CSS. The fact that its dynamic nature is lost is of no importance.
EDIT2
There is a suggestion to gram the HTML from the DOM inspector. This is what I did the first thing - in Chrome development utils copied as HTML the root html element and saved it to a file. Of course, this does not work, because it continues to reference the CSS files on the web. I guess I should have mentioned that I want it to work from the file system.
Next was to save the page as complete with all the environment using some kind of the Save menu (browser dependent). It saves the page and all the related files forming a closure, which can be open from the file system. But the html has to be manually cleaned up of all the javascript - tedious and error prone.
EDIT3
I seem to keep forgetting things. Images should be preserved, of course.
Upvotes: 3
Views: 3875
Reputation: 46359
I have to do a similar task on a semi-regular basis. As yet I haven't found an automated method, but here's my workflow:
.js
scripts which got downloaded, move everything into a single folder;script
tags at this stage because it's easier) and copy as HTML (right-click the <html>
tag. Paste this into (replace) the downloaded HTML file (remember to keep the DOCTYPE
which doesn't get copied;script
sections and delete (also delete any noscript
content), and search for on
(that's with a space at the start but StackOverflow won't render it) to remove handlers (onload
, onclick
, etc);src=
, url(
), find common patterns in image filenames and use regular expressions to replace them globally. So for example src="/images/myimage.png"
=> |/images/||
. This needs to be applied to all HTML and CSS files. Also make sure the CSS files have the correct path (href
). While doing this I usually replace all href
(links) with #
;It's a big job. I'd love a tool which automated all that, but so far I haven't found one. The pages I download are quite badly made (shops) which have a lot of unusual code, so that's why there are so many steps. You might not need to follow every step.
Upvotes: 2