/    Sign up×
Community /Pin to ProfileBookmark

Whitespace nodes

[RIGHT][COLOR=#F1F1F1]..[/COLOR][/RIGHT]

to post a comment
Full-stack Developer

13 Comments(s)

Copy linkTweet thisAlerts:
@acorbelliJun 05.2005 — Some browsers do make whitespace into an element, which I think is completely strange. I guess if this is the case it is treating whitespace like another character, and creating a javascript object out of it....so theoretically it should take some slight strain off the browser by removing it.

Though, to me it would be worth it for the ease of editing the code.
Copy linkTweet thisAlerts:
@fredmvJun 06.2005 — You may find this rather interesting:

http://www.codingforums.com/archive/index.php/t-7028.html
Copy linkTweet thisAlerts:
@BigMoosieauthorJun 06.2005 — [RIGHT][COLOR=#F1F1F1]..[/COLOR][/RIGHT]
Copy linkTweet thisAlerts:
@acorbelliJun 08.2005 — Yeah, I had thought of that, but in most cases it is better to just filter throught the nodes you are using rather than the whole document. If the document is large, that might do the opposite of my origional intent, to speed up the rendering of the page.

The method I was thinking of was removing any new line feeds and spaces between my divs in the actual source code. @ acorbelli: I would not use that as my editing version but would design a code to sift through my pages to sqeeze them smaller, and there is a second advantage, faster transfer over the internet.[/QUOTE]


So you'd write the page, run it through this parser, and then upload it? (Or it is created on the web, but still run through the script before accessing).

Sounds neat, might be a little difficult to get the script to understand the difference between a space in your wording and whitespace though, wouldn't it? Unless you use a restrictive one, such as "only remove spaces/newlines if it is between /div and div tags".

Actually, that sounds like a challenge. Hmmm. Looks like I found my next random project.
Copy linkTweet thisAlerts:
@KorJun 08.2005 — You may [i]virtually[/i] remove the [b]gaps[/b] using a DOM circle function before aplying a childNodes' based on method (because, as you might now, IE and Moz conunt in different ways the gaps - noone is strict DOM, by the way), but the question is: [b]Why[/b] you want to remove empty spaces. When you will detect the real need, you may find that, for instance, it could be easier some time to use byTagName reference or nodeType contitioner to achieve a crosbrowser code, rather than to remove all the gaps.

On the other hand, physical removing of the gaps would bring the HTML code to an unreadable one. It is almost impossible to follow a long HTML code with no gaps in it....
Copy linkTweet thisAlerts:
@BigMoosieauthorJun 08.2005 — [RIGHT][COLOR=#F1F1F1]..[/COLOR][/RIGHT]
Copy linkTweet thisAlerts:
@KorJun 08.2005 — Why would it concern me if the publishing source was hard to read?[/QUOTE]

99% of the time you will be forced to update or to modify later the page. If not you, somebody else (if the site is build for a client). It's almost like you were full payed for, let's say, a Flash menu, but you will not deliver the FLA source for a possible future updating.
Copy linkTweet thisAlerts:
@BigMoosieauthorJun 08.2005 — [RIGHT][COLOR=#F1F1F1]..[/COLOR][/RIGHT]
Copy linkTweet thisAlerts:
@KorJun 08.2005 — Ok, I see, but if you want a phisically remove of the gaps, the javascript can not help you anymore. You must find/build your own addon (or maybe some editors might do that for you). Anyway, well, I have never try to do that, so I can not tell you if there might occure some problems if doing so or not.
Copy linkTweet thisAlerts:
@acorbelliJun 08.2005 — I'd just have a php upload script that would, on upload, parse the file and remove unnecessary gaps, then move it to where you want it to go.

No JS necessary.
Copy linkTweet thisAlerts:
@BigMoosieauthorJun 08.2005 — [RIGHT][COLOR=#F1F1F1]..[/COLOR][/RIGHT]
Copy linkTweet thisAlerts:
@MongusJun 08.2005 — I've done some work in this area. You can't just remove all whitespace in between nodes because formatting will get screwed up. Even places where it shouldn't matter like between an <img> and a </td> removing spaces can change your layout.

I wrote a program to remove the extra whitespace and display the difference in an alert box. You can see it here:

http://www.mongus.net/sitediet/index.jsp

Please don't kill my server :-).

I've been thinking about making it available to the general public. Let me know what you think.
Copy linkTweet thisAlerts:
@BigMoosieauthorJun 09.2005 — [RIGHT][COLOR=#F1F1F1]..[/COLOR][/RIGHT]
×

Success!

Help @BigMoosie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...