开发者

How Can I minimize the HTML code by making it one line of code?

So I have made a web page of HTML, Inline CSS and JS. Since this page will be produced through JS function

 opened.document.write();

I would like to put all the web page code into one line that can be taken in one of the previously mention function instead of repeating the same function for every new line. I can't affors doing this manually,because the page contains too many lines of co开发者_C百科de.

Is there a fast and clean way to do this?

Notice: I used SOME PROGRAM to replace all " with \" by one click, so I hope there is away to replace all the(Enter)s with (Backspace) or something like that.


Elaboration

I want to produce the whole page when the user click on a button which will call a JS function which will produce a new page and write it using the previously mentioned function.


Hmm, well the answer is "Yes", but it's slightly disturbing what you are doing.

I don't know if you can replace special characters in Word, but in most text editors (Textpad, Notepad++) you can replace via a 'regex' so you can write "\r\n" to replace all instances of newlines with whatever you wish.

I must say, though, that I wonder why you wish to write out the document like that. Can you elaborate?


You could use an online text editor with regex, paste your code in and fix up some regex to replace \r and \n with a whitespace or no spaces. I don't know regex so you'll have to do it or ask for it yourself.


Changing your HTML pages to be generated by Javascript is a Very Bad Idea. You're making your entire website virtually invisible to Search Engines, users with javascript off, and those using screen readers, and for what benefit? Saving a couple of hundred bytes? Set up your webserver with gzip compression and proper cache control and leave the source as is.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜