+ 4

Whilst External CSS is recommended for code optimization compared to embedded CSS, does it also mean that it uses less memory?

13th Jul 2017, 9:18 PM
Happiness Kaburi
Happiness Kaburi - avatar
5 Respuestas
+ 8
No, not necessarily. The "memory" translates into load time and it depends on your site's size, how big (e.g. 20-pages) or small (e.g. single page/landpage) it is and how much CSS code you have, this could increase or decrease the download size. In terms of performance (External vs Embedded CSS), when a user goes to your website, HTTP requests are generated to the server. Every individual asset (stylesheets, scripts, images, etc) generate their own request, as well as your initial HTML file. The more requests, the slower it will load. The HTML file is the first one to be requested, received, parsed, and executed, then comes the script & stylesheet in parallel, finally other blocked resources of the DOM (e.g. images), so, when you use an external CSS it requires an extra request to the server and the parsing of that file after response. With embedded stylesheets there's just direct parsing, no delay, you don't have to wait for the stylesheet to get delivered. When to use an external CSS then? If you have a big website. It can be cached in the browser, this is useful when you're styling the same elements in multiple pages of the site. This way the browser only has to load the stylesheet once instead of having to reload the code every time the browser reloads the page.
13th Jul 2017, 11:27 PM
Pao
Pao - avatar
+ 10
In some cases you can break your styles/stylesheets into pieces and load only some of them, i.e. .CSS files for different screen resolutions that are loaded only one of all (one of a set). So comparing to the embedded CSS (that will be all completely in your html file) your styles will consume less memory (browser opening your page will consume less memory a little bit and if I'm not mistaken here data downloaded will be smaller [probably most modern browsers will preload all .css files mentioned in .html, they "preload" even other sites' resources linked in a page to "speed up browsing"... I hate it, because I am a kind of a tab-junkie opening hundreds of tabs in a session])
14th Jul 2017, 12:39 AM
Andrew Harchenko (Tomsk)
Andrew Harchenko (Tomsk) - avatar
+ 4
Sure, always welcome 😊
13th Jul 2017, 11:46 PM
Pao
Pao - avatar
+ 2
Thanx. Quite a helpful response
13th Jul 2017, 11:36 PM
Happiness Kaburi
Happiness Kaburi - avatar
0
no it doesnt
13th Jul 2017, 10:11 PM
Giannis Tsirovasilis
Giannis Tsirovasilis - avatar