<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>苏洋博客 &#187; JAVASCRIPT</title>
	<atom:link href="http://promiseforever.com/topics/learning/javascript-learning/feed" rel="self" type="application/rss+xml" />
	<link>http://promiseforever.com</link>
	<description>记录我的一点一滴。</description>
	<lastBuildDate>Sat, 12 May 2012 12:37:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>重新看待WEB前端性能</title>
		<link>http://promiseforever.com/2012/05/12/%e9%87%8d%e6%96%b0%e7%9c%8b%e5%be%85web%e5%89%8d%e7%ab%af%e6%80%a7%e8%83%bd.html</link>
		<comments>http://promiseforever.com/2012/05/12/%e9%87%8d%e6%96%b0%e7%9c%8b%e5%be%85web%e5%89%8d%e7%ab%af%e6%80%a7%e8%83%bd.html#comments</comments>
		<pubDate>Sat, 12 May 2012 02:05:37 +0000</pubDate>
		<dc:creator>苏洋</dc:creator>
				<category><![CDATA[(x)Html]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[我的总结]]></category>
		<category><![CDATA[前端]]></category>
		<category><![CDATA[重构]]></category>

		<guid isPermaLink="false">http://promiseforever.com/?p=6704</guid>
		<description><![CDATA[之前简单面试的时候,感觉回答77哥回答的不是很好. 最近又看过几本书后,有了一些新的看法，对于内容分类也有新的变化。 之前写过一篇类似的：http://promiseforever.com/2012/03/12/improve-speed-for-you.html 1.减少HTTP请求数 相同内容，相同大小的数据，10个请求数的页面肯定比100个请求数要快，浏览器和服务器建立握手，尤其在网络环境不是太理想的时候，这个问题比较突出。而且有效节约服务器资源。 2.数据内容的优化(文字,图片,CSS,JS,COOKIES,CACHE,CDN,JSON) 因为内容还原度的要求是不一样的，商品图，LOGO需要的还原度比较高，可以使用较为清晰的32位PNG或者JPG，如果是网站的边角料，可以使用gif或者16位PNG。如果有专用服务器做CDN，可以不用考虑压缩(Gzip)的问题，如果没有且服务器允许的话，对图片和文字都进行压缩的话，可以有效节约浏览器下载数据的大小。 CSS SPRITE拼合图片也可以有效节约图片体积，JS,CSS等文件在使用的时候，可以先使用YUI等压缩工具进行压缩，将只是给开发人员看的缩进内容都省略，顺便一提，对于IE较老的版本，CSS,JS的分号和滤镜中的某些空格不能随便压缩掉，如果随意压缩掉，会发生想要的效果消失掉的BUG。 鉴于访客来源地区的差异，合理使用CDN也是一个不错的方案。 例如CSS,JS这些额外的表现和行为的元素，如有可能，单独保存为外部文件，在HTML文档中引用的位置最优方案为：css位于文档头部，利于尽早渲染页面，核心JS库可以适当放置较早的位置，比如jquery，其他的js文件放置于页面尾部，有可能的话，尽量拼合这些文档，js如果包含较多数据，可以使用eval packed二次压缩。 cache可以使用etag,expire,或者HTML5-cache进行缓存,使用JS进行调用或者遵循浏览器的默认规则，有效减少重复下载内容的时间。 cookies要谨慎使用，避免发生cookies 污染，因为浏览器存在带cookies发送请求，所以cookies的大小必须在合理范围，虽然它最大也只是4kb,正确设置过期时间,合理减少不必要内容,是优化的有效手段.. JSON作为数据交换手段之一,比xml的优越性还是蛮多的,首先是它体积更小,传输更快,速度是网站的基础之一。而且JSON可以描述出对象，十分适合进行小段的程序间的通信。 3.减少DOM操作 DOM树庞大，很多操作DOM的时候是进行整体拷贝，然后遍历设置属性的过程，这个操作是很浪费时间的，如果有可能，使用XPATH,或者直接操作某个带有ID的元素，更为快捷和节约资源。使用DOM的时候，必须合理进行局部的VAR保存一下操作中会重复利用到的对象。 4.页面重构 在对DOM元素进行操作之后，如果该元素会影响到其他的元素，例如其他元素的上下文是它，那么其他元素会进行重排，在它进行重新渲染生成的时候。重新渲染元素需要消耗内存和时间，如果页面包含许多元素，重排的时间和资源也不容小觑。 DOM结构如果不能保持简明良好，反复嵌套无用的结构，不仅在重排的时候会造成浪费，而且影响后续开发。]]></description>
		<wfw:commentRss>http://promiseforever.com/2012/05/12/%e9%87%8d%e6%96%b0%e7%9c%8b%e5%be%85web%e5%89%8d%e7%ab%af%e6%80%a7%e8%83%bd.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[转]命名空间的使用</title>
		<link>http://promiseforever.com/2012/05/11/%e8%bd%ac%e5%91%bd%e5%90%8d%e7%a9%ba%e9%97%b4%e7%9a%84%e4%bd%bf%e7%94%a8.html</link>
		<comments>http://promiseforever.com/2012/05/11/%e8%bd%ac%e5%91%bd%e5%90%8d%e7%a9%ba%e9%97%b4%e7%9a%84%e4%bd%bf%e7%94%a8.html#comments</comments>
		<pubDate>Fri, 11 May 2012 15:10:26 +0000</pubDate>
		<dc:creator>苏洋</dc:creator>
				<category><![CDATA[C & C++]]></category>
		<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[命名空间]]></category>

		<guid isPermaLink="false">http://promiseforever.com/?p=6694</guid>
		<description><![CDATA[关于命名空间. 来源:http://www.cnblogs.com/anytao/archive/2010/10/22/anytao-devstory-15-use-namespace-in-js.html Introduction How to have a better code organization? When your software become bigger and bigger, the code will torture you all the time. So, the smart guy innovate the Namespace to handle this issue. For example, in .NET world, we define the class in scope of namespace: namespace Anytao.Common &#123; public class Console ...]]></description>
		<wfw:commentRss>http://promiseforever.com/2012/05/11/%e8%bd%ac%e5%91%bd%e5%90%8d%e7%a9%ba%e9%97%b4%e7%9a%84%e4%bd%bf%e7%94%a8.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DOM获取集合元素效率比较</title>
		<link>http://promiseforever.com/2012/04/11/dom%e8%8e%b7%e5%8f%96%e9%9b%86%e5%90%88%e5%85%83%e7%b4%a0%e6%95%88%e7%8e%87%e6%af%94%e8%be%83.html</link>
		<comments>http://promiseforever.com/2012/04/11/dom%e8%8e%b7%e5%8f%96%e9%9b%86%e5%90%88%e5%85%83%e7%b4%a0%e6%95%88%e7%8e%87%e6%af%94%e8%be%83.html#comments</comments>
		<pubDate>Wed, 11 Apr 2012 12:46:08 +0000</pubDate>
		<dc:creator>苏洋</dc:creator>
				<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Jquery]]></category>
		<category><![CDATA[效率]]></category>

		<guid isPermaLink="false">http://promiseforever.com/?p=6644</guid>
		<description><![CDATA[很好奇JQUERY选择器,HTML-DOM,DOM-CORE三个DOM操作起来的速度.. 执行jQuery(&#8216;form&#8217;);发现返回数组. 执行document.forms;一样返回数组. document.getElementsByTagName(&#8220;form&#8221;);返回对象.. 猜测HTML-DOM快于DOM-CORE,JQUERY 不确定(后来想到,这个东西是warp的javascript,理论应慢) HTML的根是WINDOWS,DOM-CORE的根是DOCUMENT. 使用如下代码进行测试,因为语句简单,所以需要增大循环次数来进行比较. &#60;script&#62; var START=new Date&#40;&#41;.getTime&#40;&#41;; for &#40;i=0;i&#60;1000;i++&#41;&#123; &#160; //测试语句 &#160; &#125; var END=new Date&#40;&#41;.getTime&#40;&#41; - START; alert&#40;&#34;total:&#34;+END+&#34;ms&#34;&#41;; &#60;/script&#62; 测试DOM-CORE的语句为: document.getElementsByTagName(&#8220;form&#8221;); 测试HTML-DOM的语句为: document.forms; JQUERY-DOM语句为: jQuery(&#8216;form&#8217;); 执行结果为: 12ms 10ms 7ms 6ms 3ms 6ms 108ms 90ms 89ms 所以&#8230;HTML-DOM > DOM-CORE > JQUERY-DOM]]></description>
		<wfw:commentRss>http://promiseforever.com/2012/04/11/dom%e8%8e%b7%e5%8f%96%e9%9b%86%e5%90%88%e5%85%83%e7%b4%a0%e6%95%88%e7%8e%87%e6%af%94%e8%be%83.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Metro JS</title>
		<link>http://promiseforever.com/2012/03/31/metro-js.html</link>
		<comments>http://promiseforever.com/2012/03/31/metro-js.html#comments</comments>
		<pubDate>Sat, 31 Mar 2012 15:35:19 +0000</pubDate>
		<dc:creator>苏洋</dc:creator>
				<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Metro]]></category>

		<guid isPermaLink="false">http://promiseforever.com/?p=6570</guid>
		<description><![CDATA[分享一个metro js效果库.感觉很好。 浏览网站]]></description>
		<wfw:commentRss>http://promiseforever.com/2012/03/31/metro-js.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>防止统计数据出错</title>
		<link>http://promiseforever.com/2012/03/23/%e9%98%b2%e6%ad%a2%e7%bb%9f%e8%ae%a1%e6%95%b0%e6%8d%ae%e5%87%ba%e9%94%99.html</link>
		<comments>http://promiseforever.com/2012/03/23/%e9%98%b2%e6%ad%a2%e7%bb%9f%e8%ae%a1%e6%95%b0%e6%8d%ae%e5%87%ba%e9%94%99.html#comments</comments>
		<pubDate>Fri, 23 Mar 2012 01:48:43 +0000</pubDate>
		<dc:creator>苏洋</dc:creator>
				<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[判断]]></category>

		<guid isPermaLink="false">http://promiseforever.com/?p=6535</guid>
		<description><![CDATA[不知道老外童鞋是怎么想的,不过这样确实可以提醒copy代码的人是否误把他人统计进行使用.. 其实把判断中的内容修改为添加脚本元素可以主动避免这种事情的发生.. window.onload = function&#40;&#41; &#123; var host = window.location.host; if&#40;host != &#34;yourdomain.com&#34; &#38;&#38; host != &#34;www.yourdomain.com&#34; &#38;&#38; host != &#34;translate.googleusercontent.com&#34; &#38;&#38; host != &#34;subbane.yourdomain.com&#34;&#41; &#123; alert&#40;&#34;Hey, it looks like you may have accidentally copied my analytics code (perhaps from a demo of mine?). Could you please remove it? Thanks a bunch! - Neal Grosskopf&#34;&#41;; ...]]></description>
		<wfw:commentRss>http://promiseforever.com/2012/03/23/%e9%98%b2%e6%ad%a2%e7%bb%9f%e8%ae%a1%e6%95%b0%e6%8d%ae%e5%87%ba%e9%94%99.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>新浪微博批量删除</title>
		<link>http://promiseforever.com/2012/03/14/%e6%96%b0%e6%b5%aa%e5%be%ae%e5%8d%9a%e6%89%b9%e9%87%8f%e5%88%a0%e9%99%a4.html</link>
		<comments>http://promiseforever.com/2012/03/14/%e6%96%b0%e6%b5%aa%e5%be%ae%e5%8d%9a%e6%89%b9%e9%87%8f%e5%88%a0%e9%99%a4.html#comments</comments>
		<pubDate>Wed, 14 Mar 2012 14:20:37 +0000</pubDate>
		<dc:creator>苏洋</dc:creator>
				<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[删除]]></category>
		<category><![CDATA[新浪]]></category>

		<guid isPermaLink="false">http://promiseforever.com/?p=6443</guid>
		<description><![CDATA[转自http://b.wych.me/auto-delete-sina-tweets.wych，删除速度小慢。 觉得微博数量太多有点小傻&#8230;删除点吧.虽然没有实名认证微博,但是实名认证了SAE这些&#8230; 我觉得实名倒是没什么的，因为我确定我会奉公守法。 言论上也会尽力保持自己想要的克制，因为我急需长大。 // batch delete posts script for weibo.com // 批量删除新浪微博帖子代码 // // By Paul Lan, 基督教北京守望教会弟兄小方 // Last Modified: 2011年11月13日00时51分03秒 // // usage: // 1. you should go to your personal page first // 2. excute this script via firebug console in Firefox, or via console in Chrome -- sorry for IE ...]]></description>
		<wfw:commentRss>http://promiseforever.com/2012/03/14/%e6%96%b0%e6%b5%aa%e5%be%ae%e5%8d%9a%e6%89%b9%e9%87%8f%e5%88%a0%e9%99%a4.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5画玫瑰</title>
		<link>http://promiseforever.com/2012/03/09/html5%e7%94%bb%e7%8e%ab%e7%91%b0.html</link>
		<comments>http://promiseforever.com/2012/03/09/html5%e7%94%bb%e7%8e%ab%e7%91%b0.html#comments</comments>
		<pubDate>Fri, 09 Mar 2012 00:00:08 +0000</pubDate>
		<dc:creator>苏洋</dc:creator>
				<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[玫瑰]]></category>

		<guid isPermaLink="false">http://promiseforever.com/?p=6255</guid>
		<description><![CDATA[HTML5画的玫瑰,很漂亮,使用支持HTML5的浏览器的朋友不妨看看.. &#60;html&#62; &#60;head&#62; &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=UTF-8&#34;/&#62; &#60;title&#62;3D Rose(By JS)&#60;/title&#62; &#60;/head&#62; &#60;body&#62; &#60;canvas id=&#34;c&#34;&#62;&#60;/canvas&#62; &#60;script&#62; var b = document.body; var c = document.getElementsByTagName('canvas')[0]; var a = c.getContext('2d'); document.body.clientWidth; &#60;/script&#62; &#60;script&#62; // start of submission // with(m=Math)C=cos,S=sin,P=pow,R=random;c.width=c.height=f=500;h=-250;function p(a,b,c){if(c&#62;60)return[S(a*7)*(13+5/(.2+P(b*4,4)))-S(b)*50,b*f+50,625+C(a*7)*(13+5/(.2+P(b*4,4)))+b*400,a*1-b/2,a];A=a*2-1;B=b*2-1;if(A*A+B*B&#60;1){if(c&#62;37){n=(j=c&#38;1)?6:4;o=.5/(a+.01)+C(b*125)*3-a*300;w=b*h;return[o*C(n)+w*S(n)+j*610-390,o*S(n)-w*C(n)+550-j*350,1180+C(B+A)*99-j*300,.4-a*.1+P(1-B*B,-h*6)*.15-a*b*.4+C(a+b)/5+P(C((o*(a+1)+(B&#62;0?w:-w))/25),30)*.1*(1-B*B),o/1e3+.7-o*w*3e-6]}if(c&#62;32){c=c*1.16-.15;o=a*45-20;w=b*b*h;z=o*S(c)+w*C(c)+620;return[o*C(c)-w*S(c),28+C(B*.5)*99-b*b*b*60-z/2-h,z,(b*b*.3+P((1-(A*A)),7)*.15+.3)*b,b*.7]}o=A*(2-b)*(80-c*2);w=99-C(A)*120-C(b)*(-h-c*4.9)+C(P(1-b,7))*50+c*2;z=o*S(c)+w*C(c)+700;return[o*C(c)-w*S(c),B*99-C(P(b, 7))*50-c/3-z/1.35+450,z,(1-b/1.2)*.9+a*.1, P((1-b),20)/4+.05]}}setInterval('for(i=0;i&#60;1e4;i++)if(s=p(R(),R(),i%46/.74)){z=s[2];x=~~(s[0]*f/z-h);y=~~(s[1]*f/z-h);if(!m[q=y*f+x]&#124;m[q]&#62;z)m[q]=z,a.fillStyle=&#34;rgb(&#34;+~(s[3]*h)+&#34;,&#34;+~(s[4]*h)+&#34;,&#34;+~(s[3]*s[3]*-80)+&#34;)&#34;,a.fillRect(x,y,1,1)}',0) // end of submission // &#60;/script&#62; &#60;/body&#62; &#60;/html&#62; 提示:你可以先修改部分代码再运行。]]></description>
		<wfw:commentRss>http://promiseforever.com/2012/03/09/html5%e7%94%bb%e7%8e%ab%e7%91%b0.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>[javascript]Raphaël SVG矢量图</title>
		<link>http://promiseforever.com/2012/03/05/raphael-svg.html</link>
		<comments>http://promiseforever.com/2012/03/05/raphael-svg.html#comments</comments>
		<pubDate>Mon, 05 Mar 2012 00:34:16 +0000</pubDate>
		<dc:creator>苏洋</dc:creator>
				<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Raphaël]]></category>
		<category><![CDATA[svg]]></category>

		<guid isPermaLink="false">http://promiseforever.com/?p=6193</guid>
		<description><![CDATA[原文出处:http://raphaeljs.com/ 使用方法很简单,只需要把js库引用到你的HTML文件中即可. // Creates canvas 320 × 200 at 10, 50 var paper = Raphael&#40;10, 50, 320, 200&#41;; &#160; // Creates circle at x = 50, y = 40, with radius 10 var circle = paper.circle&#40;50, 40, 10&#41;; // Sets the fill attribute of the circle to red (#f00) circle.attr&#40;&#34;fill&#34;, &#34;#f00&#34;&#41;; &#160; // Sets the ...]]></description>
		<wfw:commentRss>http://promiseforever.com/2012/03/05/raphael-svg.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SVG+VML测试</title>
		<link>http://promiseforever.com/2012/03/04/svgvml%e6%b5%8b%e8%af%95.html</link>
		<comments>http://promiseforever.com/2012/03/04/svgvml%e6%b5%8b%e8%af%95.html#comments</comments>
		<pubDate>Sun, 04 Mar 2012 00:44:19 +0000</pubDate>
		<dc:creator>苏洋</dc:creator>
				<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[svg]]></category>
		<category><![CDATA[vml]]></category>

		<guid isPermaLink="false">http://promiseforever.com/?p=6185</guid>
		<description><![CDATA[原文出处. 半年前看过国外一个大牛的一个demo，然后自己用他的思路写了一个类似的东西。加了点额外的功能。 　　当时主要是为了学习svg的部分api，做着玩。 &#60;!DOCTYPE html&#62; &#60;html&#62; &#60;head&#62; &#60;meta charset=&#34;utf-8&#34; /&#62; &#60;title&#62;Rag Doll&#60;/title&#62; &#60;meta name=&#34;Author&#34; content=&#34;hongru.chen&#34; /&#62; &#60;style _mce_bogus=&#34;1&#34;&#62;&#60;!-- html { overflow: hidden; } ul,ol { margin: 0; padding: 0; list-style:none; } body { margin: 0px; padding: 0px; background: #222; position: absolute; width: 100%; height: 100%; } #screen { position: absolute; left: 6%; top: 10%; width: ...]]></description>
		<wfw:commentRss>http://promiseforever.com/2012/03/04/svgvml%e6%b5%8b%e8%af%95.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>背景滑动脚本</title>
		<link>http://promiseforever.com/2012/03/02/background-scrolling.html</link>
		<comments>http://promiseforever.com/2012/03/02/background-scrolling.html#comments</comments>
		<pubDate>Thu, 01 Mar 2012 23:55:21 +0000</pubDate>
		<dc:creator>苏洋</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[背景滑动]]></category>

		<guid isPermaLink="false">http://promiseforever.com/?p=6169</guid>
		<description><![CDATA[话说这个似乎前一阵很流行.贴下代码吧. &#60;script type=&#34;text/javascript&#34;&#62; jQuery&#40;function&#40;$&#41; &#123; /* Scrolling Background */ var currentOffset = &#91;0, 0&#93;; var backgroundImage = new Image&#40;&#41;; var updateBackground = function&#40;&#41; &#123; currentOffset&#91;0&#93; = currentOffset&#91;0&#93; - 1 % backgroundImage.width; var attributeString = currentOffset&#91;0&#93; + &#34;px &#34; + currentOffset&#91;1&#93; + &#34;px&#34;; $&#40;'body'&#41;.css&#40;'background-position', attributeString&#41;; setTimeout&#40;updateBackground, 100&#41;; &#125;; backgroundImage.onload = function &#40;&#41; &#123;updateBackground&#40;&#41;;&#125; backgroundImage.src = &#34;_static/TekapoSky.jpg&#34;;&#125;&#41;; ...]]></description>
		<wfw:commentRss>http://promiseforever.com/2012/03/02/background-scrolling.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

