RE: Help me with my new website!
February 11, 2018 at 11:21 pm
(This post was last modified: February 11, 2018 at 11:28 pm by bennyboy.)
(February 10, 2018 at 3:54 pm)FlatAssembler Wrote:No, it isn't.Quote: Why would the webhost care if you split your code up?Well, if I make a separated JS file and a CSS file along with the HTML file, the browser will have to connect to the server three times to download all of them, and now it only has to connect once. Isn't that how it works?
The javascript and .css files will be cached and reused by your browser, saving bandwidth overall. The cost of an individual connection for text files is so unimportant that it's 100% not worth considering at all; people have internet hardware capable of handling dozens of simultaneous connects pumping away at megabytes/second each. But either way, it really doesn't matter. There's no amount of text file that you are likely to send that will have much impact on any modern user. Consider this: I have the entire texts of some children's books in my database, like Alice in Wonderland and so on. The text for one book will download in maybe 0.1 seconds or less.
Every .css file you have ever written, or will ever write, will not all together amount even to a tiny portion of that one interaction.
Quote:Yes. You have .css files with class names defining how you want objects to be positioned. You do not have "loads" of css, because the entire point of css is to prevent you from having to define a lot of stuff in your markup.Quote: You should invest all the time it takes to redo things properly, preferably using only .css for formatting the UI.I mean, the primary reason I can't change the appearance of my app is that I was using loads of absolute positioning inside the CSS. Is there an alternative to it for such apps?
I think when you say you have "loads" of css, what you mean is you are injecting css attributes into controls that you are creating using javascript. Don't do this. Even when making custom controls, you give them .css class names-- then whenever you change your styles, those 100 controls will be styled properly.
The only time you do programmatic .css is when you want to change attributes client-side that cannot be rendered server side: for example, if you have a button to grow or shrink fonts as the user prefers and don't want to post back the whole page.