Html Bootstrap 很慢如何让它更快
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24948530/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bootstrap is very slow how to make it faster
提问by user3864461
My site is : Design Spicy
我的网站是:设计辣
my website is slow during the bootstrap.css and js
我的网站在 bootstrap.css 和 js 期间很慢
Load time : 3.56s (by pingdom) bootstrap.css : 97.9 kB bootstrap.js : 28.7
加载时间:3.56 秒(通过 pingdom) bootstrap.css:97.9 kB bootstrap.js:28.7
by Google pagespeed Checker
由谷歌页面速度检查器
Compressing http://designspicy.com/…tent/themes/desgnspycy/css/bootstrap.css could save 80.8KiB (82% reduction).
Compressing http://designspicy.com/…content/themes/desgnspycy/js/jquery-1.js could save 59.3KiB (64% reduction).
Compressing http://designspicy.com/…ontent/themes/desgnspycy/js/bootstrap.js could save 20.9KiB (73% reduction).
Compressing http://designspicy.com/ could save 10.8KiB (74% reduction).
Compressing http://designspicy.com/wp-content/themes/desgnspycy/style.css could save 5.9KiB (70% reduction).
i uses bootstrap for mobile optimize css but my site load time is low any suggestion.
我使用引导程序进行移动优化 css,但我的网站加载时间很短,没有任何建议。
采纳答案by Hyman
Another suggestion is using a content delivery network, or CDN
, that hosts your files like Bootstrap
and jQuery
. That way, if a user has already visited a site where Bootstrap (or jQuery) is loaded using the same CDN, those files will be cached in the browser.
另一个建议是使用内容交付网络,或CDN
,托管您的文件,如Bootstrap
和jQuery
。这样,如果用户已经访问了使用相同 CDN 加载 Bootstrap(或 jQuery)的站点,这些文件将被缓存在浏览器中。
Another advantage of CDN? They tend to be optimized for quick delivery of such files to users (for ex., based on location of user, the CDN decides the best server/ fastest - to the user...)
CDN的另一个优势?它们往往针对将此类文件快速交付给用户进行了优化(例如,根据用户的位置,CDN 决定最佳服务器/最快 - 给用户......)
A quick Google search points to this CDN for Bootstrap: http://www.bootstrapcdn.com/
一个快速的谷歌搜索指向这个用于 Bootstrap 的 CDN:http: //www.bootstrapcdn.com/
回答by Ulrich Schwarz
As pagespeed says, enable gzip compression (for textual content -- many image formats are already compressed) in your web server. How to do it depends on what server you run; for Apache httpd 2.2, an incantation like
正如 pagespeed 所说,在您的 Web 服务器中启用 gzip 压缩(用于文本内容——许多图像格式已经被压缩)。怎么做取决于你运行的服务器;对于 Apache httpd 2.2,像这样的咒语
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE \
text/html text/plain text/xml application/xhtml+xml \
text/css \
text/javascript application/x-javascript application/javascript
</IfModule>
will compress your usual suspects as they're transmitted to the client.
将压缩您通常的嫌疑人,因为它们被传输到客户端。
回答by Hyman
Analyse your classes and its properties in CSS of bootstrap.There can be many properties which may be not needed for you. So you can remove that freely. And make a single class for commonly initialized properties. So your code will be reduced. And this can affect your page speed. Thanks.
在 bootstrap 的 CSS 中分析您的类及其属性。可能有许多您不需要的属性。所以你可以自由地删除它。并为通常初始化的属性创建一个类。所以你的代码会减少。这会影响您的页面速度。谢谢。