Technology News

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

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);
}
Elon Musk’s problematic plan for “full self-driving” Teslas
Cartona gets $4.5M pre-Series A to connect retailers with suppliers in Egypt

Related Articles

What the Heck Are npm Commands?

what-the-heck-are-npm-commands
npm is, as you now know, a package manager. But like similar, earlier tools that run tasks in the command line, such as Grunt and Gulp, npm can also run…

How to fix Facebook

how-to-fix-facebook
Facebook is broken, and after a recent deluge of damning internal company leaks to the press and Congress, the world has unassailable proof of how troubled it really is. Almost…