473,320 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Javascript/CSS limitations?

Hi There,

I was wondering if there is any sort of limit to stylesheet classes that browsers may have. Here is what is happening.

I have a massive javascript codebase ive been asked to work on which has 215 css classes defined using javascript document.writes for every line which equals thousands of document.writes. There is also a function which goes through all the elements on the page and returns/changes the stylesheet for the element from the 215+ available.

At 215 elements and thousands of document.writes it is fine, but when you go past 216 elements, it automatically causes firefox to freeze and crash, internet explorer also doesnt crash but the script does stop functioning.

I have been unable to find any one with similiar problems relating to possible similar causes (maximum document.writes/classes/style properties that browsers can handle).

just wondering if anyone can verify what sort of limits browsers do have, and also offer any other suggestions as to what may be causing this delicate and awkward behaviour to happen.

Kind Regards,
Steve
Aug 27 '07 #1
13 2149
phvfl
173 Expert 100+
Hi,

The default timeout for scripts in Firefox is 5 seconds, I suspect this is the same in IE. The timeout is there so that if there is an unresponsive script then that script can be terminated instead of using resources on the client.
Aug 27 '07 #2
hi,

Further information: Firefox freezes and crashes before the normal script termination dialog even has a chance to initiate.

Thanks,
Steve
Aug 27 '07 #3
acoder
16,027 Expert Mod 8TB
Is there no way you can make this more efficient by replacing the document.writes? Is there any reason why document.write is being used?
Aug 27 '07 #4
i believe it was used because this same problem was happening with string concantenation at such large lengths at fewer lines. However the problem has now re-appeared using document.writes.
Aug 27 '07 #5
gits
5,390 Expert Mod 4TB
hi ...

as far as i know there are memory-limitations with string-handling at such large numbers ... and i think there are better ways to achieve the goal of creating a document ... use dom-methods that create nodes, append childs etc. ... so the number of stringoperations decreases dramatically

kind regards
Aug 27 '07 #6
so even with document.writes there is a maximum as to what you can use? The node idea is a good idea, but the problem is the majority of output is infact stylesheet classes. There isnt anymore than 200 lines of html. Anymore ideas to get around this limitation would be appreciated. Thx

Thanks,
Steve
Aug 28 '07 #7
acoder
16,027 Expert Mod 8TB
Could you post some code so we can have a look.
Aug 28 '07 #8
not exactly sorry, there is far too much code (any small bit of code wouldnt really prove anything as it is all 100% valid javascript code, and simple for loops and document.writes for the most part), and the problem isnt so much with the code, but the amount of stuff being written to the screen using javascript

Thx,
Steve
Aug 28 '07 #9
gits
5,390 Expert Mod 4TB
hmmm ... so in that case the only thing that might be of help is to simply link the styles and prepare them on the server-side already ... then write the css-link (include) to the document and send that to the client ...
Aug 28 '07 #10
yeah i was thinking of doing this, but unfortunately it uses javascript variables to fill in image locations and fill in height and width to avoid using css hacks and stuff like this which means this isnt really an option either :(

Thanks,
Steve
Aug 28 '07 #11
gits
5,390 Expert Mod 4TB
what about reducing this to the necessary steps? ... prepare everything that is possible and then set the rest with js ...

kind regards
Aug 28 '07 #12
hi

Thanks, i tried this and it fixed the problem!
Aug 30 '07 #13
gits
5,390 Expert Mod 4TB
hi ...

glad to hear that you got it working :) ... post back to the forum whenever you have more questions

kind regards
Aug 30 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
1
by: Julius Mong | last post by:
Dear all, according to the ASV3 manual known problem section, to make an <a> execute some Javascript onclick: ...
16
by: zwetan | last post by:
Hi, often I see people telling that "javascript sucks" - is it because of the DOM with JS ? - is it because of the language in itself ? - is it because browsers/hosts differences ? - is it...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
5
by: Roman | last post by:
Hi, I am relatively new to dotnet and have heard great things about form validation and how easy it is. While I can see some improvements compared with classic asp I am a bit disappointed at...
2
by: aeroguy | last post by:
hi i have amotorokr e6 phone and its supports javascript. The phone itself works on a linux OS. I want to write a simple program in javascrpt that can do input output operation in the mobile.......
20
by: shapper | last post by:
Hello, How to create a namespace in Javascript containing two methods? And how to access those methods? Thanks, Miguel
84
by: Patient Guy | last post by:
Which is the better approach in working with Javascript? 1. Server side processing: Web server gets form input, runs it into the Javascript module, and PHP collects the output for document prep....
93
by: lorlarz | last post by:
Here, let's see what you JavaScript programmers have got Here is a place to share your large or larger full-blown JavaScript applications: real.comp.lang.js.apps (a new google group) Here is...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.