Resources aren’t requested by CSS, but by the DOM

This is a good tweet from Harry:


The post Resources aren’t requested by CSS, but by the DOM appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.


This content originally appeared on CSS-Tricks and was authored by Chris Coyier

This is a good tweet from Harry:

I like it because, as he says, it’s the correct way to think about it. It helps form a mental model of how websites work.

Just to spell it out a bit more…

/*
  Just because I'm in the CSS, doesn't mean I'll load!
  In order for `myfont.woff2` to load, a selector needs to 
  set `font-family: 'MyWebFont';` AND something in the DOM
  needs to match that selector for that file to be requested.
*/
@font-face {
  font-family: 'MyWebFont';
  src: url('myfont.woff2') format('woff2');
}

/*
  Just because I'm in the CSS, doesn't mean I'll load!
  In order for `whatever.jpg` to load, the selector
  `.some-element` needs to be in the DOM. 
*/
.some-element {
  background-image: url(whatever.jpg);
}

The post Resources aren’t requested by CSS, but by the DOM appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.


This content originally appeared on CSS-Tricks and was authored by Chris Coyier


Print Share Comment Cite Upload Translate Updates
APA

Chris Coyier | Sciencx (2021-09-20T23:16:14+00:00) Resources aren’t requested by CSS, but by the DOM. Retrieved from https://www.scien.cx/2021/09/20/resources-arent-requested-by-css-but-by-the-dom/

MLA
" » Resources aren’t requested by CSS, but by the DOM." Chris Coyier | Sciencx - Monday September 20, 2021, https://www.scien.cx/2021/09/20/resources-arent-requested-by-css-but-by-the-dom/
HARVARD
Chris Coyier | Sciencx Monday September 20, 2021 » Resources aren’t requested by CSS, but by the DOM., viewed ,<https://www.scien.cx/2021/09/20/resources-arent-requested-by-css-but-by-the-dom/>
VANCOUVER
Chris Coyier | Sciencx - » Resources aren’t requested by CSS, but by the DOM. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/20/resources-arent-requested-by-css-but-by-the-dom/
CHICAGO
" » Resources aren’t requested by CSS, but by the DOM." Chris Coyier | Sciencx - Accessed . https://www.scien.cx/2021/09/20/resources-arent-requested-by-css-but-by-the-dom/
IEEE
" » Resources aren’t requested by CSS, but by the DOM." Chris Coyier | Sciencx [Online]. Available: https://www.scien.cx/2021/09/20/resources-arent-requested-by-css-but-by-the-dom/. [Accessed: ]
rf:citation
» Resources aren’t requested by CSS, but by the DOM | Chris Coyier | Sciencx | https://www.scien.cx/2021/09/20/resources-arent-requested-by-css-but-by-the-dom/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.