简体   繁体   中英

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 code.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM