Technology

Turn to | Next Page

Import Junkie

As I was working on a software application at work, I noticed that my primary CSS file was now requiring its own zip code. Concerned with keeping my style information healthy, I began diagnosis and treatment immediately. The problem was that every single file being was imported though the master CSS file. This need not be the case as there were some style documents that were specific to certain sections of the program.

For Example

  • Global Documents
    • layout.css
    • content.css
    • listing.css
  • Page & Section Specific
    • appointment.css
    • claims.css

So you may be asking what is the point to all this. Well, by removing section specific files and linking them in the HTML as normal, I saved at least one thousand lines of code from being loaded every time a page is sent to the browser. If that weren’t enough, I added a PHP script to compress the large CSS files on the fly, to further enhance performance.

@import
@import Rule

The moral of the story is to use the import rule for documents which style global content, but think twice about importing unnecessary information. Granted we have browser caching to alleviate some CSS load time, but when working on complex projects that load JavaScript event handlers and PHP processors to boot, streamlining a bit can’t hurt.

More Information

If you are unfamiliar with @rules, check out the good folks at WestCiv. They offer detailed tutorials for just about every CSS topic. Resources for the PHP compression script can be found at the following locations;

Happy importing…

Technology
3/9/2007
8:07 pm

Comments Off

Turn to | Next Page

You are currently browsing the archives for Technology.

Tuesday March, 9, 2010

XHTML + CSS = 508