减小 html 大小

发布于 2024-10-19 07:37:34 字数 113 浏览 3 评论 0原文

有人对如何减小主页大小有建议吗 http://www.floorsandchores.net

Does anyone have a suggestion on how i can reduce my home page size please
http://www.floorsandchores.net

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

回梦 2024-10-26 07:37:34

所有其他答案都是正确的,但您可以进行额外的微调。 ;-)

1.) 你有一百万零一个不间断的空格用于对齐...使用 CSS 而不是这个:

     

2.) 必须有一些比 1999 年左右的 Macromedia 预加载器更好的图像预加载。

3.) 使用服务器端注释,这些注释不会被推送到客户端

4.) 您的代码中有大量空的 onclick="" 处理程序。如果你不需要它们,就把它们撕下来。

5.) 删除所有空的 font 标签、强标签以及未使用的 div

6.) 除非您将其覆盖为内联,否则不需要添加 display:block 到你的 div

7.) 你的 favicon 是一个 BMP 文件...它应该是 IE 的 ICO(和/或现代浏览器的 PNG)

8.) 删除右键单击拦截器 - 没有意义不再在其中了。所有浏览器都会以您无法阻止的方式完全公开整个 HTML/JS/CSS,供任何人查看。

9.) 删除/重构针对 IE4 和 Netscape6 的 JavaScript - 这两个浏览器几年前就已经消失了

10.) 你已经声明了这个元标记两次...

11.) 您可能不需要在链接上使用此内容:target="_self"

All of the other answers are correct, but there is additional fine tuning you can do. ;-)

1.) You have a million-and-one non-breaking spaces used to do alignment... use CSS instead of this:

     

2.) There has to be some better image preloading than the Macromedia preloaders from circa 1999.

3.) Use server-side comments, that don't get pushed to the client

4.) You have a ton of empty onclick="" handlers in your code. If you don't need them, rip them out.

5.) Delete all your empty font tags, and strong tags, and divs that aren't being used

6.) Unless you overrode it to be inline, you don't need to add display:block to your div's

7.) Your favicon is a BMP file... it should be ICO for IE (and/or PNG for modern browsers)

8.) Drop the right-click blocker - there's no point in it anymore. All browsers fully expose the entire HTML/JS/CSS for anyone to see in ways you can't block.

9.) Remove/Refactor the JavaScript that is targetting IE4 and Netscape6 - both of these browsers died years ago

10.) You have this meta tag declared twice... <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

11.) You likely don't need this on the links: target="_self"

叹沉浮 2024-10-26 07:37:34

如果您使用 YSlowGoogle Page Speed 他们会告诉您哪种优化可以提高网站的性能。我可以看出你没有对你的 html、js 文件等进行 gzip:ing。打开 gzip 将大大减少下载到客户端的大小。

If you use a tool such as YSlow or Google Page Speed they will tell you what kind of optimizations that would increase the performance of your site. I can tell that your not gzip:ing your html, js-files and so on. Turning on gzip will reduce the size that gets downloaded to the client drastically.

忆依然 2024-10-26 07:37:34

您是否正在考虑以千字节为单位的大小?

您的页面当前大小为 182K。这还不是很多。

要了解您网站的大小或了解如何优化加载速度,我建议 firebug for firefox 和 yahoo 的 yslow (添加到 firebug) - 它会告诉您可以了解页面大小、如何优化网站等。

根据 YSlow 的说法,您目前的成绩为 C,这还算不错。


页面加载速度

如果您正在考虑加快网站速度,有几种方法。

要加快页面速度,您可以执行以下操作:

  • 您当前有 7 个 javascript 文件和 5 个 css 文件。 css 文件可以合并为一个,而 javascript 文件可以减少到(我认为)两个或三个。
  • 实际上,您应该将 javascript 文件放在右下角结束 标记之前
  • 您可以添加“过期标头” - 您可以在 .htaccess 中执行此操作文件(至少在 apache 服务器上)——这不会影响新用户,但经常来的用户会感觉到不同。

GZip 压缩

您可以在您的网站上启用 gzip 压缩。有一个 apache 插件 - 但不确定你的主机是否兼容。但这会大大减小尺寸。

Are you thinking about size in kilobytes?

Your page is currently 182K. That's not a whole lot.

To find out the size of your site of find out how to optimize the loading speed, I recommend firebug for firefox and yahoo's yslow (add on to firebug) - it will tell you the page size, how you can optimize the site etc.

According to YSlow, you're currently getting a grade of C, which isn't so bad.


Page loading speed

If you're thinking about speeding your site up, there are a few ways.

To speed up the page you can do a few things:

  • You currently have 7 javascript files, and 5 css files. The css files can be combined into one and the javascript files can be reduced to (I think) two or three.
  • You should actually place the javascript files at the bottom right before the closing </body> tag
  • You can add "expires headers" - you can do that in an .htaccess file (on apache servers at least) - this won't affect new users, but users that come often will feel a difference.

GZip compression

You could enable gzip compression on your website. There is a plugin for apache - but it's not certain that your host is compatible. But this will reduce the size considerably.

超可爱的懒熊 2024-10-26 07:37:34

相对而言,这不是一个很大的文档,但如果我的员工提交代码进行审查,我会告诉他们:

  • Javascript 是老式的(看起来
    自动生成?)你可以
    尽量减少您发送的内容
    使用 JQuery 处理每个请求
    或者在诸如翻转之类的情况下
    图片,纯CSS。
  • CSS 可用于删除重复元素,例如 font-size: 10px;,该元素在页面上内嵌了 17 次。只需为字体设置一个 CSS 属性,font-size=10px(或者更好的是,为 html 设置一个 CSS 属性并为子选择器设置百分比)
  • 通过 CSS 优化器
  • 使用语义标记,这将清理页面并有助于 SEO!
  • 合并 CSS 文档以减少 HTTP 请求量
  • 检查 W3 Validator。本身并不节省空间,但您当前报告了 18 个错误

It isn't a huge document relatively speaking, but here's what I'd tell my employees if they presented the code for review:

  • The Javascript is old-school (looks
    to be auto-generated?) and you could
    minimize what you're sending across
    on each request by utilizing JQuery
    or in cases such as the rollover
    images, pure CSS.
  • CSS could be used to remove repetitive element such as the font-size: 10px; which is done 17 times in-line on the page. Just set a CSS property for font with font-size=10px (or better yet, set one for the html and do percentages for child selectors)
  • Run the page through a CSS optimizer
  • Use semantic markup, which will clean up the page and also help with SEO!
  • Combine CSS documents to lower the amount of HTTP Requests
  • Check in a W3 Validator. Doesn't save space per se, but you are currently reporting 18 errors
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文