BLOG: Embedding or Attaching?

You have two methods: embedding and attaching. Which is better?

The answer is, attaching. By far.

I like attaching scripts and style sheets. It allows me to use the same script file or style sheet on as many Web pages as I want, which is invaluable for frequently used functions like rollovers or popup menus and sitewide styles. If I tried to embed these things, I'd have to copy and paste the same blocks of code over and over again onto each and every page that requires them. This seems to me like a waste of time, not to mention bandwidth. The visitor's browser has to load the embedded stuff again and again, while the browser caches attached files.

Even more importantly, if I want to change something late in the process, ...

Get Web Design Garage now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.