ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a BASIC program that produces 2 HTML or PHP files from the same input text file, one is formatted without removing unnecessary spaces and newlines, the other file has these characters removed and produces a single string (about 40k in my problem case), they are then checked with the W3C validator and they are always found to be valid code.
This program gives a .PHP extension if there are "include" statements in the file, or a .HTM extension if there is not.
The reason for this sort of compression is that I have read somewhere some time ago that doing so will make the file download faster to a visitor's computer.
The problem is that, although they render correctly and without error on my machine they do not from the Internet server. When I display the file from the Internet server, it appears as one line overwritten on itself and when trying to render it, I get an error message saying an unexpected "/" has been found.
When I display the same file on my computer, it takes a long time to load but it shows as a single string and it renders correctly.
My questions are:
What could the problem be?
Should I do it differently?
1.
would be helpful if you post the source code of the html/php file your browser receives. In general sorting out the whitespace from html files does not make the page much faster.
2.
Are there include statements in the text so that we expect PHP? If so -as I assume- maybe there are some quotes missing or sth like that...
A 40K long text line?
Please! What if you ever want to inspect the HTML code? Happy scrolling.
You will not achieve any worthwhile speed increase. But you will break any parser/editor/viewer that (wrongfully) doesn't expect a text file to have a forty thousand character long line.
In fact, anything above 80 chars per line will potentially become a nuisance to someone looking at the code.
The only PHP code is those "include" statement like this:
<?php include '../charts/p1.chart01.php'; ?>
The Internet site provider uses Linux and I use UTF-8. When I said it takes a long time to load, this is in "gedit", between 4 seconds to 35 seconds (for 40k) but this could be due to a bug in my system because I regularly have messages like "window not responding" for no apparent reason, we could not solve this problem. The rendering of the file through the browser is instantaneous with firefox but I have just discovered iceweasel displays the file in bluefish instead of rendering it and this is also very slow.
If there is little or no advantage in "compressing" the file into a string, as j-ray mentioned, then it is much safer to use the "uncompressed" file as it gives no problem and I will do that.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.