网页优化
我正在创建一个新的动态网站来测试和了解网络优化... 站点索引
对于 html、css、js(链接到 google 服务器的 jquery-min 除外)文件,我已经创建了一个 php 文件,该文件连接更多文件,删除未使用的空格,并使用 Gzip 对其进行压缩: 压缩的 css - 压缩js
if(extension_loaded('zlib')){ob_start('ob_gzhandler');
/*...php code to read files and remove comments/spaces*/
if(extension_loaded('zlib')){ob_end_flush();}
对于主图像,我将每个图像折叠成 one
对于类似 facebook 的按钮,我在页面加载后替换 iframe使用 jquery,我想对 adbrite 广告做同样的事情,但我不知道如何.. 如果我尝试替换或在加载后将代码注入到 html 中,页面就会消失并仅保留广告...
有人可以帮忙吗?
你能告诉我我是否做得很好(优化)以及我可以改进的地方吗?
谢谢......
I'm creating a new dinamic site to test and learn about web optimization...
Site Index
For html,css,js (exept jquery-min that is linked to google server) files I've created a php file that concatenate more files, remove unused spaces, and compress it using Gzip:
compressed css - compressed js
if(extension_loaded('zlib')){ob_start('ob_gzhandler');
/*...php code to read files and remove comments/spaces*/
if(extension_loaded('zlib')){ob_end_flush();}
For main images, I collapsed every image into one
For facebook like button, I replace the iframe after page load using jquery, I'd like to do the same with adbrite advertises but I don't know how..
If I try to replace, or inject the code into html after loading, the page disapper and remain only the adv...
Someone could help?
Can you tell me if I'm doing well (for optimization) and where I can improve
Thanks...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个好的开始,但您不应该动态压缩任何内容。这成本太高,并且最终会比交付未压缩的内容慢。
使用 gzip/deflate 并使用 YUI、Google 闭包编译器 或 uglifyjs 等压缩器压缩您的 javascript 文件来命名几个。静态提供这些文件。
Apache ANT 是一个很好的工具,可以自动执行所有上述过程(以及更多......)。
supplyJS 是一个很好的库,可以通过一个流动态提供任何内容。
It's a good start, but you shouldn't compress anything dynamically. That is just too costly and will end up to be slower than delivering content uncompressed.
Use gzip/deflate and compress your javascript files with a minifier like YUI, Google's closure compiler or uglifyjs to name a few. Serve those files statical.
A nice tool to automate all of the above processes (and way more..) is Apache ANT.
A nice library to serve any content dynamically over one stream is supplyJS.
您还可以尝试 Google Granule:http://code.google.com/p/capsule/ (以编程方式动态压缩和缩小 css 文件和 js 文件)
还要检查您的“adbrite 广告”是否不起作用,因为代码可能使用
Document.write()
方法,该方法应该在解析文档时被调用。尝试异步或延迟加载它们。http://www.sitepoint.com/non-blocking-async-defer/
You can also try Google Granule: http://code.google.com/p/granule/ (which programmatically compresses and minifies css files and js files on the fly)
Also check your "adbrite advertises" is not working is because the code might be using a
Document.write()
method, which should be called while the document is being parsed. try loading them asynchronously or deferred.http://www.sitepoint.com/non-blocking-async-defer/