无法通过Page Speed Insights传递渲染阻止css / js问题

问题描述 投票:0回答:1

我想尽可能快地优化我的网站。在Google Page Speed Insights,我一直在阅读建议,并已经做了很多。我似乎无法通过的一件事是渲染阻塞css / js问题。我有一个.htaccess文件,我正在压缩我的CSS和javascript与mod_deflate。我读到mod_deflate是传递此问题的最佳方法,但我仍然得到一个css文件的渲染阻塞问题,https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css

我最初虽然可能是因为它是CDN,但它没有被我的其余文件压缩,但我一直在读,通过渲染块css / js的解决方案是使用CDN。无论如何在没有编写大量关键内联样式的情况下解决这个问题?也许我需要在我的.htaccess文件中添加一些额外的东西,或者我可以加载CDN的方式?

.htaccess文件

Options +FollowSymLinks
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/javascript "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"

</IfModule>

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

#Begin gzip and deflate
<IfModule mod_deflate.c>

# compress text, html, javascript, css, xml:
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE image/png
AddOutputFilterByType DEFLATE image/jpg
AddOutputFilterByType DEFLATE text/html

# DEFLATE NOT COMPATIBLE BROWERS
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

<IfModule mod_headers.c>
Header append Vary User-Agent
</IfModule>

</IfModule>

<IfModule mod_pagespeed_ap24.c>
ModPagespeed on
ModPagespeedInheritVHostConfig on
ModPagespeedEnableFilters rewrite_css,combine_css
ModPagespeedEnableFilters recompress_images
ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp
ModPagespeedEnableFilters collapse_whitespace,remove_comments
</IfModule>
css twitter-bootstrap-3 google-pagespeed mod-deflate
1个回答
1
投票

从CDN下载“bootstrap.min.css”并将其托管在您自己的服务器上,然后在您网站的页脚上调用它,您的问题就会得到解决。

关心Manoj Soni

© www.soinside.com 2019 - 2024. All rights reserved.