SitePoint Sponsor

User Tag List

Results 1 to 23 of 23
  1. #1
    ********* Ornithologist AtomicPenguin's Avatar
    Join Date
    May 2002
    Location
    Vancouver, BC
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    maximum javascript code in IE browsers...?

    Hi all,

    (I love this forum! :-)

    Q: I have a pretty big html page - about 1,500 lines of code, 1,000 of which is javascript. (It's also referencing other javascript code, perhaps another 2,000 lines or so).

    When I boot up the page in a fresh browser, it invariably crashes; the page just hangs. But, after killing the browser, and opening it up in a new one, the page seems to run fine. Is there some sort of javascript code limit that a web page / browser can handle...? Anyone know if there's a way to get around this? [Did I misread the problem? I'm pretty sure my code is fine.]

    If you're curious to see the page, go here:
    http://www.littlebluedot.net/htmlare...nterface6.html

    Note: the page uses code that only runs in IE 5.5+.

    Thanks, guys.

  2. #2
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice page. I use some htmlArea stuff on my page as well.

    Ran fine here, tested it a bunch of different times, with different numbers of windows open, etc.

    Worked great every time.

    (Win2003/IE6SP1)
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  3. #3
    SitePoint Wizard aaron.martone's Avatar
    Join Date
    Feb 2003
    Location
    Florida, USA
    Posts
    2,322
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Neat lookin script there. Works perfectly fine for me. Let me ask, are you running on a rather low powered machine? Low memory?

    I have 512MB PC2100 DDR memory on a WinXP Pro system using MSIE 6, and it worked fine.

  4. #4
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ran fine for me too, and I have 512 MB SDRAM, Windows 2k Pro, MSIE 6 (the browser I used to load the page)...I guess you could make the file a bit less lengthy by using more external JS files, but I'm not sure if that would decrease load time or not.

  5. #5
    ********* Ornithologist AtomicPenguin's Avatar
    Join Date
    May 2002
    Location
    Vancouver, BC
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, guys. It's not fully functional yet, but it's getting there... :-) I'd rather hoped it wouldn't work for you, though... (the irony!)

    I'm running a pretty decent machine - Pentium 4, 1.8GHz, 512MB RAM, so it doesn't seem to be that. I'm using IE 6, too.

    The reason this is a real concern is because I've crashed that page on four separate computers, now - 3 around our office & 1 at home. It doesn't seem to be an isolated case.

    [I miss straightforward coding bugs already... ]

  6. #6
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    About your question.......
    You can put as much JS as you want, but it needs to be placed either externally or at the bottom of your HTML. Otherwise it pushes the HTML to the bottom of the page, making it less important to search engine bots. Check webmasterworld.com, googles affiliated site, for help on search engine suggestions.
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  7. #7
    ********* Ornithologist AtomicPenguin's Avatar
    Join Date
    May 2002
    Location
    Vancouver, BC
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool. Thanks for the info.

    So any other thoughts about what might be causing the problem? Would splitting up the javascript into manageable chunks in external files help? (just going on a hunch).

  8. #8
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    automatic penguin........

    I urgently suggest you put some text into your intro-page, Search engines will love it........
    Dislike pages without
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  9. #9
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    you could try using loops if possible. I noticed you had alot of similar code. See if you can shorten it into loops, as this helps the file size. Have you checked it with the w3c validation? That helps for any HTML code that might be out, and having the validation line at the top of your script makes it work better. (If its validated).

    Also check the script layout. I had a puzzling problem for ages, then realised that one of my mouseover functions was triggering before it actually knew what to move. Offline the code worked too fast to notice, but online it showed, and gave an error, but only when I first went to the page. If I refreshed, because most of it was already loaded, it worked fast enough to ignore the error.
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  10. #10
    ********* Ornithologist AtomicPenguin's Avatar
    Join Date
    May 2002
    Location
    Vancouver, BC
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks again! But to be honest, search engine friendliness really isn't my top concern right now - I'm just concerned with making it fully functional. This page-loadup issue is my #1 priority.

    But thanks for the coding tips; you're right - there are bits of code that can be simplified & shortened. The code is pretty ugly right now, and there's a lot to fix up!

    Thanks again.

  11. #11
    Idea Developer
    Join Date
    Sep 2000
    Location
    Bethlehem, PA
    Posts
    521
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just ran it on p366 96 megs of ram win 98 ran fine
    Professional PHP programing / Hosting
    aim: downtoi3iz icq: 74637813

  12. #12
    SitePoint Enthusiast Sabretooth's Avatar
    Join Date
    Apr 2002
    Location
    Gettysburg, PA (USA)
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It works fine here on Win98 with IE 5.5 (using a frontend to supress popups too, which usually mucks up scripts but it didn't in this case) with 512mB of ram. The final generated window came up fine.
    Worked just as well in AOL 4 too, which dies on almost every geocities page.

  13. #13
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What sort of connection are you connecting to the site with? Broadband?
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  14. #14
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd go through the code and optimize everything you can. Try to make sure there are no loading/timing issues (script accessing objects that aren't yet initialized, etc).

    If you see lots of for loops, see if you can't make them into while loops. Number of code-lines here is less significant than code speed, and while loops are much faster.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  15. #15
    ********* Ornithologist AtomicPenguin's Avatar
    Join Date
    May 2002
    Location
    Vancouver, BC
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good grief - doesn't ANYONE have any problems? I'm starting to look at my computer in a whole new way...

    Great tip on the for / while loops. I had no idea while's were quicker. (You haven't got a reference for that, do you? Where did you find that out?)

    Other questions: I'm on a nice fast connection here at my company - 100MB / sec from what I understand.

  16. #16
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AtomicPenguin
    Other questions: I'm on a nice fast connection here at my company - 100MB / sec from what I understand.
    Holy ****! I have a 56k and it ran perfectly fine for me, you might want to check that computer of yours out or something...

    Oh and BTW, you don't need to go as crazy as Beetle has with trying to save namespace...really, don't waste your time. If anything, putting a lot of your JS code into JS files should help.

  17. #17
    SitePoint Enthusiast
    Join Date
    Feb 2003
    Location
    Toronto
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great script!!
    Ran fine on my Athlon1.8G, 512mb ram, win2000, ie6

  18. #18
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    gregc - maybe if you actually knew what you were talking about you could make such comments. The truth is, namespace-conservation and speed-optimization (the topic at hand here) are wholly unrelated. Namespace conservation is about avoiding conflicts. Moving code into external files will help download speed, but not execution speed. I'm sorry I offended you last time, but please, drop the subject before you make further erroneous comments.

    penguin - I don't have a reference per-se, but have run some tests. You can see the results here.

    What seems to be evident from these tests (run several times to get an average)
    • References help loop
    • Object tests are faster than incremental
    • IE is much slower using typeof than Gecko is
    • While loops are fastest only when using an object test
    Since while loops perform much better in object scenarios, I'd recommend going with them since your page most likely involves lots of object handling. Also, it's evident that creating references is a good performance boost as well.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  19. #19
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by beetle
    Moving code into external files will help download speed, but not execution speed.
    The problem was never execution speed, go read the first post...the problem was that the browser would crash upon loading, not after it was loaded. Heck, here's the quote for you:

    Quote Originally Posted by AtomicPenguin
    When I boot up the page in a fresh browser, it invariably crashes; the page just hangs.
    So if I'm not mistaken, external JS files would help in this situation.

  20. #20
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If loading was the problem then why would it be okay on your 56k?

    After looking at the code, I think it's a bit of both
    Code:
    document.write('<scr'+'ipt src="' +_editor_url+ 'editor_generate.js" language="Javascript1.2"></scr'+'ipt>');
    HTML added via document.write or innerHTML manipulation takes extra time for the browser to parse it into the node tree. So, because of the download delay, an optimization flaw is created.

    I would change this to use a DOM appending method, or just include the file manually into the HTML.

    Since his page uses pre-onload scripting, it's hard to say if it's download time or not.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  21. #21
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If loading was the problem then why would it be okay on your 56k?
    Well it seems that the creator of this script (AtomicPenguin) has been the only one who has had any problems with the script... So it may just be his (or her) computer. But at any rate, keeping code in external files is always helpful and makes it easier to manage everything.

  22. #22
    ********* Ornithologist AtomicPenguin's Avatar
    Join Date
    May 2002
    Location
    Vancouver, BC
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey guys,

    By the sounds of it, everyone can run it fine. Hmph. (If it runs on 56K the issue sure isn't connection speed!) I've had it hang on three separate computers around the office, but with further testing I've found it inconsistent.

    Since there doesn't seem to be anything blatantly wrong with what I'm doing, I think I'm just going to go ahead and overhaul (and finish!) the code and see if the problems disappears. I think I may well be grouping the code into an external file or files - more for the sake of easy comprehension than anything else. That may well help clear up the issue. Who knows...!

    Ultimately, it has to work with everyone's (IE) browser to even bear consideration of being released as an interactivetools htmlArea add-on -- hence my concern. A couple of days ago, when I sent a version of it to my boss - the creator of htmlArea- it crashed his browser. That really doesn't look good...! ;-)

    But thanks for everyone's input, it's been much appreciated! :-)

  23. #23
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're welcome...let us know if the problem is fixed when you're done, k?


Bookmarks

Posting Permissions

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