This plugin hasn’t been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

Delay Print CSS

Description

Many browsers will not render your webpage until the print.css is loaded. Delay Print CSS prevents this from happening. Once your page has fully rendered (including JavaScript, images, etc) your print stylesheets will be loaded.

Using the methods described in a recent blog post this plugin uses JavaScript, with a non JavaScript fallback, to load your stylesheets last.

If your WordPress site uses jQuery then it is used to load the stylesheets, otherwise the plugin outputs its own JavaScript.

Installation

Upload delay-print-css to the /wp-content/plugins/ directory of your install.

Activate the plugin through the ‘Plugins’ menu in WordPress

In your theme or plugin, use wp_register_style and/or wp_enqueue_style to load your CSS. This requires you to remove any html tags you have in your theme and add the following code to your functions.php file:

function mytheme_enqueue_css(){   if (!is_admin()){     wp_enqueue_style (       'mytheme-print', /* handle */       '/path-to/print.css', /* source */       null, /* no requirements */       '1.0', /* version */       'print' /* media type */     );   } } add_action('wp_print_styles', 'mytheme_enqueue_css'); 

To wrap your stylesheet in conditional tags, add the following below the wp_enqueue_style call in your new function

global $wp_styles; $wp_styles->registered['mytheme-print']->extra['conditional'] = 'IE 6' 

FAQ

I use jQuery but the plugin outputting its own JavaScript

You may not be loading your JavaScript the WordPress way. If wp_enqueue_script means nothing to you, then have a read of a tutorial I wrote on the subject

My stylesheets aren’t been loaded any differently

Make sure you are using wp_enqueue_style to load your CSS, an explanation is in the Installation section of this readme file.

Can I use IE conditional comments

Yes. If you set your stylesheet to be for a particular version of IE, this plugin will respect that.

Is this plugin safe to use on a production site?

This plugin was written as a proof of concept, has a sub 1.0 version number and has been tested for a few common situations only. I don’t use it on a production website but let me know of your experiences if you choose to.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“Delay Print CSS” is open source software. The following people have contributed to this plugin.

Contributors

Translate “Delay Print CSS” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.