www.webdeveloper.com
Results 1 to 14 of 14

Thread: Whitespace nodes

  1. #1
    Join Date
    Feb 2005
    Location
    USA
    Posts
    1,534
    ..
    Last edited by BigMoosie; 11-24-2005 at 03:27 AM.

  2. #2
    Join Date
    Mar 2005
    Location
    CA
    Posts
    323
    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.
    -Anthony

  3. #3
    Join Date
    Jul 2003
    Location
    Boston Area, Massachusetts
    Posts
    3,489
    You may find this rather interesting:

    http://www.codingforums.com/archive/...hp/t-7028.html

  4. #4
    Join Date
    Feb 2005
    Location
    USA
    Posts
    1,534
    ..
    Last edited by BigMoosie; 11-24-2005 at 03:27 AM.

  5. #5
    Join Date
    Mar 2005
    Location
    CA
    Posts
    323
    Quote Originally Posted by BigMoosie
    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.
    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.
    -Anthony

  6. #6
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    You may virtually remove the gaps 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: Why 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....

  7. #7
    Join Date
    Feb 2005
    Location
    USA
    Posts
    1,534
    ..
    Last edited by BigMoosie; 11-24-2005 at 03:27 AM.

  8. #8
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by BigMoosie
    Why would it concern me if the publishing source was hard to read?
    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.

  9. #9
    Join Date
    Feb 2005
    Location
    USA
    Posts
    1,534
    ..
    Last edited by BigMoosie; 11-24-2005 at 03:27 AM.

  10. #10
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    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.

  11. #11
    Join Date
    Mar 2005
    Location
    CA
    Posts
    323
    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.
    -Anthony

  12. #12
    Join Date
    Feb 2005
    Location
    USA
    Posts
    1,534
    ..
    Last edited by BigMoosie; 11-24-2005 at 03:27 AM.

  13. #13
    Join Date
    Mar 2005
    Location
    Gilbert, AZ
    Posts
    293
    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.

  14. #14
    Join Date
    Feb 2005
    Location
    USA
    Posts
    1,534
    ..
    Last edited by BigMoosie; 11-24-2005 at 03:27 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles