CSS 文件加载时间性能问题

标签 css wordpress

我正在尝试加快我的网站速度,看起来加载以下两个文件非常耗时。

volumewatchers.com/?itx=css&ver=3.5.1 volumewatchers.com/?itx=js&ver=3.5.1

这些文件非常小,我看不出有什么理由让它们加载将近 2 秒。

Pingdom 报告: http://tools.pingdom.com/fpt/#!/cdpj8h/http://volumewatchers.com/

看起来 itx wordpress 主题正在尝试通过 wp-enqueue 动态加载这些文件。由于模板几乎已设置好,我可以在该部分中对这些文件进行硬编码。有人可以建议我如何调整此代码并对这些文件进行硬编码吗?我查看了源代码并创建了一个 .CSS 文件。但是,它并没有多大帮助。

这里是 header.php 代码:-

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>"  />
<title><?php wp_title(''); ?></title>
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> latest post RSS" href="<?php echo itx_get_option('links','rss') ?>" />
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> latest comment RSS" href="<?php echo itx_get_option('links','crss') ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri()?>/css/ie6.css">
<![endif]-->
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri()?>/css/ie7.css">
<![endif]-->
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" />  
<?php
    if (is_singular() && get_option( 'thread_comments' )) wp_enqueue_script( 'comment-reply' );
    if (is_active_widget(false,false,'itx_tabbed_sidebar')||!is_active_sidebar(1)) wp_enqueue_script('jquery-ui-tabs');
    if ( itx_get_option('misc','nohover') == 0 ) wp_enqueue_script('jquery-color');
    wp_enqueue_script('itx',get_bloginfo('url').'/?itx=js');
    wp_enqueue_style('itx',get_bloginfo('url').itx_preview_vars('css'));
    wp_head();
?>

谢谢!

最佳答案

您是否考虑过合并您的文件?我注意到您使用了 4 个样式表(+ 一些内联样式)和 19 个 javascript 文件。如果您可以将它们合并到一个(缩小的)css 和尽可能少的(缩小的)js 文件中,您可能会获得一些速度。通常,浏览器请求文件然后下载一些额外的字节需要更长的时间,因此最好尽可能少地发出请求。

关于CSS 文件加载时间性能问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16761105/

相关文章:

需要 HTML 解析未知选择器

html - 带有粘性页眉和页脚的 2 列布局

javascript - Wordpress 有条件地加载一个缩小的脚本

php - Visual Composer 添加 ?id= 到列和行的背景图像

javascript - JS fetch,没有得到响应的标题

html - float 文本到图像的右侧

html - 使 Html 标签显示在 Div 元素的右侧

html - Div 背景不显示解决方案是什么?

wordpress - 如何使用 Contact Form 7 添加 Font Awesome 图标到 WordPress 中的提交按钮?

css - 带有 CSS 的仪表板的固定菜单、(可选)固定子菜单和内容区域