[wordpress插件] Delay Print CSS延迟打印CSS

wordpress 插件 文章 2020-04-14 19:50 578 0 全屏看文

AI助手支持GPT4.0

评分
0
描述

Many browsers will not render your webpage until the print.css is loaded.

在加载print.css之前,许多浏览器都不会渲染您的网页。

Delay Print CSS prevents this from happening.

延迟打印CSS可以防止这种情况的发生。

Once your page has fully rendered (including JavaScript, images, etc) your print stylesheets will be loaded.

页面完全呈现(包括JavaScript,图像等)后,您的打印样式表将被加载。

Using the methods described in a recent blog post

使用最近的博客文章中所述的方法

a> this plugin uses JavaScript, with a non JavaScript fallback, to load your stylesheets last.

a>此插件使用具有非JavaScript后备功能的JavaScript来最后加载样式表。

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

如果您的WordPress网站使用jQuery,则将其用于加载样式表,否则插件将输出其自己的JavaScript。

安装步骤

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

将delay-print-css上载至安装目录的 / wp-content / plugins / 目录。

Activate the plugin through the ‘Plugins’ menu in WordPress

通过WordPress中的“插件”菜单激活插件

In your theme or plugin, use wp_register_style and/or wp_enqueue_style to load your CSS.

在主题或插件中,使用 wp_register_style 和/或 wp_enqueue_style 加载CSS。

This requires you to remove any html tags you have in your theme and add the following code to your functions.php file:

这要求您删除主题中包含的所有html标记,并将以下代码添加到您的functions.php文件中:

function mytheme_enqueue_css(){   if (!is_admin()){     wp_enqueue_style (       'mytheme-print', /* handle */       '/path-to/print.css', /* source */       null,

  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 */ );

/ *不需要* /'1.0',/ *版本* /'print'/ *媒体类型* /);

} } add_action('wp_print_styles', 'mytheme_enqueue_css');

}} 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

要将样式表包装在条件标签中,请在新函数的wp_enqueue_style调用下方添加以下内容

global $wp_styles;

 全局$ wp_styles; 

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

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

下载地址
https://downloads.wordpress.org/plugin/delay-print-css.0.1.zip
-EOF-

AI助手支持GPT4.0