How to compress HTML page source into one line?

harrygreen90

Active member
Joined
Dec 17, 2013
Messages
413
Points
28
When browsing websites and viewing lots of webpages' source code (like JS,CSS,HTML) on the internet, I find all the codes are in one line. How could they do that? Do they use some tools or php codes to make it? Can we restructure it?
 

RDO Servers

New member
Joined
Apr 3, 2015
Messages
770
Points
0
It's called modification

Google "minify HTML"

You will find lots of resources for minifying and un-minifying HTML/CSS/javascript
 

Web Marketing Tool

New member
Joined
Apr 30, 2016
Messages
41
Points
0
To do it yourself search google for "Compress JS", "Compress CSS", "Compress HTML". All of these searches will give you top results with free online tools that are easy to do this with (just takes a few seconds).

The sites allow you to choose how much to compress. For me I don't recommend doing FULL compression where everything is on one line. Like the css compressor I use has 4 settings. The highest setting compresses all on one line. I use the next setting down which still compresses everything a lot, but leaves each element on it's own line so it is easier to read.

Compressing things too much can make debugging a real pain. And it doesn't really stop theft of code, it's more for page speed, so I wouldn't do the most compressed form of html, css or js. Not of course, I'm a coder and I often debug stuff in FireFox/Chrome so for me an even bigger pain if code is not easily human readable.

To take minified code and return it to being readable you can use a site like unminify.com
 

Mike001

New member
Joined
Apr 27, 2016
Messages
578
Points
0
I agree with the posts that have been written but just wanted to add that unless there is a lot of code on the pages, and were talking thousands of lines, the minification of the code for increase speed of load purposes is very marginal.

As an computer science engineer, I have actually completed a couple of studies on this for my own purposes and found that with the increased speeds of the internet connections, the multi-tasking processors with multi-bus capabilities, the increase in the bus lines, and the multiple cores that are now dedicated to individual tasking, speed boosts, on an average size file of 100K or less, and that is about the size of an average size webpage, the file load time is decreased marginally. Less than 1/10 of 1 second.

Now as the pages get bigger and they access data files those times can increase significantly. But what I found there is that the page itself did not impact load times near as much as the structure of the data being accessed. Relational data sets that are not properly structured and optimized can have a tremendous impact on load times of a web page. Hence the issues with WordPress, Joomla and Drupal to name a few.

There databases are not very well structured and when you get someone designing a site with those front ends, that understands nothing about optimized data structures all hell can break loose. But I digress.
 
Latest threads
Replies
2
Views
368
Replies
1
Views
366
Replies
4
Views
1,888
Replies
3
Views
794

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top