Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the source code for some web pages all in one line?

When viewing lots of webpages' source code (like JS,CSS,HTML), I find them in one line. How did they make this? Do they use some tools to make it? Can we restructure it?

Thanks.

like image 706
Jason Avatar asked Jun 18 '12 04:06

Jason


People also ask

Why is JavaScript all one line?

You'll find the script has been put in one line when it is 'minified'. This means that unnecessary white space and all comments have been removed. A Script file is minified to reduce the size of the JavaScript file in order to optimise it for download from the server to the client browser.

How do I find the full source code of a website?

To view only the source code, press Ctrl + U on your computer's keyboard. Right-click a blank part of the web page and select View Page Source from the pop-up menu that appears.

What is the source code of a website?

Source code is a human-readable text written in a specific programming language. The goal of the source code is to set exact rules and specifications for the computer that can be translated into the machine's language. As a result, source codes are the foundation of programs and websites.

Are all web pages coded in HTML?

HTML is at the core of every web page, regardless the complexity of a site or number of technologies involved. It's an essential skill for any web professional. It's the starting point for anyone learning how to create content for the web. And, luckily for us, it's surprisingly easy to learn.


1 Answers

It's minified HTML, i.e. with the whitespace removed.

There are many tools that can do this, you can find them by Googling for minify HTML.

To un-minify it or beautify it as they say, you can google for beautify HTML.

The same applies to CSS. It can be minified and beautified.


Javascript can also be minified however most tools nowadays obfuscate the symbols which means that although you could beautify it, it will be harder to understand it afterwards.

The alternative to Javascript minification is the Javascript Packer

like image 101
Marko Avatar answered Nov 15 '22 17:11

Marko