Archive for the ‘Arsa’ Category

 

If you read your question again, you have answered it yourself. There is a reason for the “separation” of html and CSS. Because at some point in time, you will eventually want to change the look of what you have coded up. These are the times when having a separate CSS file would be very helpful so you are only ever making changes in one place and not throughout your application.

EDIT

Another usefulness of having the CSS separate is the caching. Most of the modern browsers cache the CSS files. This means there are less round-trips to the server and quicker response times. I’m not sure if same is the case for JavaScript, because JavaScript files would be cached, but the client browser will have to execute the code every time it loads.

answered 1 hour ago
I think I didn’t explain well. All the css is done in a different way: you create a new UI Object and will have a look based on it’s properties. If object.backgroundColor = ‘black’, then when will generate the html will create <div style=”background-color:black”/>; Then if I want to change in all object that color I just set that on the main “class” of the UI Object or a javascript theme will be provided. I will never have to cache CSS or HTML as they dont really exists in my code. My code only knows that “backgroundColor” will convert in “background-color” for css, and a new UI object will – Totty 1 hour ago
be created in a new <div> tag. So if I need to change the look I will make a javascript theme (that is app specific) and then my javascript will generate all the html+css based on the new properties. If I want to have css only on a specific element, it will be set at the instance level. ps.: I haven’t answered myself because I already said that separation is not a concern as is abstracted by javascript. – Totty 1 hour ago
Hmm, I see what you mean. Although I have never done it before, I suspect there will be a significant difference in page load times in both methodologies. Have you done any load time calculations using both these options using firebug/yslow or any other tools you might be using. Not saying what you are doing is incorrect but there must be a reason there is an emphasis put on having separate CSS files. Also, the approach you are taking could also be changed so that all your CSS rules are produced in a separate file and the generated HTML only had <div id=”XYZ”></div>. Your call! :-)  – Hiral Desai 56 mins ago
In my case the page load time will be defined by the time to “download the code” + “code execution” + “dom generation” vs “html download” + “css download” + “javascript download” + “code execution”. In my option, the “dom generation” will be heavier than the other approach. But I have no “css & html download” time. Now the time difference is based on internet-speed & browser & ui-objects-number. Javascript can’t generate a separate css file but can generate a separate style tag with all css rules (at runtime, as all I speak here is generated at runtime). But will be a pain to remove and change – Totty 32 mins ago
Başlıklar