HTML5¼¼Êõ

´óÁ÷Á¿ÍøÕ¾ÐÔÄÜÓÅ»¯£ºÒ»²½Ò»²½´òÔìÒ»¸öÊʺÏ×Ô¼ºµÄBigRender²å¼þ - º«×Ó³Ù(2)

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2016-03-16 13:00 ÎÒÒªÆÀÂÛ( )

ÎÒÃÇͨ¹ýÕýÔò½« js ºÍ css ±êÇ©²¿·ÖÈ¡³ö£º extractCode: function(str, isStyle) { var cata = isStyle ? style : script, scriptFragment = + cata + [^]*([\\S\\s]*?)/ + cata + \\s*, matchAll = new RegExp(scr

ÎÒÃÇͨ¹ýÕýÔò½« js ºÍ css ±êÇ©²¿·ÖÈ¡³ö£º

extractCode: function(str, isStyle) { var cata = isStyle ? "style" : "script" , scriptFragment = "<" + cata + "[^>]*>([\\S\\s]*?)</" + cata + "\\s*>" , matchAll = new RegExp(scriptFragment, "img") , matchOne = new RegExp(scriptFragment, "im") , matchResults = str.match(matchAll) || [] , ret = []; for (var i = 0, len = matchResults.length; i < len; i++) { var temp = (matchResults[i].match(matchOne) || [ "", "" ])[1]; temp && ret.push(temp); } return ret; }

³É¹¦µØ½« script ÒÔ¼° style ±êÇ©ÄÚµÄÄÚÈÝÌáÈ¡Á˳öÀ´£¬ÇÉÃîµØÓÃÁËÕýÔòÖеÄ×Ó±í´ïʽ¡£

evalScripts/evalStyles

½Å±¾Ö´ÐУ¬ÑùʽäÖȾ¡£

evalScripts: function(code) { var head = doc.getElementsByTagName("head")[0] , js = doc.createElement("script"); js.text = code; head.insertBefore(js, head.firstChild); head.removeChild(js); }, evalStyles: function(code) { var head = doc.getElementsByTagName("head")[0] , css = doc.createElement("style"); css.type = "text/css"; try { css.appendChild(doc.createTextNode(code)); } catch (e) { css.styleSheet.cssText = code; } head.appendChild(css); } ÓÅȱµã & ÊÊÓó¡¾°

¼òµ¥½²½² BigRender ÓÅ»¯µÄÓÅȱµã£¬ÒÔ¼°ÊÊÓó¡¾°¡£

ÓŵãºÜÃ÷ÏÔ£¬ÒòΪ¼õÉÙÁËÊ×ÆÁ DOM µÄäÖȾ£¬ËùÒÔÄܼӿìÊ×ÆÁ¼ÓÔصÄËٶȣ¬²¢ÇÒÄÜ·Ö¿é¼ÓÔØ js/css£¬·Ç³£ÊÊÓÃÓÚһЩģ¿éÇø·Ö¶ÈºÜ¸ßµÄÍøÕ¾£¨¸öÈ˾õµÃ´óÐÍÍøÕ¾µÄÄ£¿éÇø·Ö¶ÈÆÕ±éÔ½À´Ô½¸ßÁË£©¡£

ȱµãÊÇÐèÒª¸ü¸Ä DOM ½á¹¹£¨DOM ½ÚµãµÄÌæ»»ºÍäÖȾ£©£¬¿ÉÄÜ»áÒýÆðһЩÖØÅźÍÖػ档һЩûÓпªÆô js ¹¦ÄܵÄÓû§½«¿´²»µ½ÑÓ³Ù¼ÓÔصÄÄÚÈÝ£¨¿ÉÒÔÓà noscript ±êÇ©¸ø³öÒ»¸öÉÆÒâÌáÐÑ£©¡£×î´óµÄȱµã¿ÉÄÜÊDz»ÀûÓÚ SEO£¬Ò»Ð©ÒÀÀµÓÚ SEO µÄÍøÕ¾¿ÉÄÜÐèÒªÔÚ SEO ÉÏϵ㹦·òÁË£¬±ÈÈçÃÀÍÅ¡£

¹ØÓÚ SEO£¬¿ÉÒÔ¿´Ï Õâ¸öÍøÕ¾£¬ÄÜÄ£ÄâËÑË÷ÒýÇæÖ©Öë¶ÔÍøÕ¾µÄÅÀÈ¡Çé¿ö¡£ÃÀÍŶÔÓÚ BigRender ÒÔ¼° SEO ½â¾ö·½°¸ [ÃÀÍÅÍø°¸Àý]¸ÄÉÆBigRender¼¼Êõµ¼ÖµÄSEOÎÊÌâ

bigrender ͨ¹ý¼õÉÙ DOM ½Úµã£¬¼Ó¿ìÊ×ÆÁµÄäÖȾ£¬µ«ÊÇ£¬ËüÒ²ÊÇÓжîÍâµÄÐÔÄÜËðºÄµÄ£¬äÖȾǰtextarea ÀïÃæµÄ html ´úÂ룬ÔÚ·þÎñ¶Ë°Ñ html ´úÂë±£´æÔÚÒþ²ØµÄ textarea ÀïÃ棬ËùÒÔÔÚ·þÎñ¶Ë»á°Ñ html ´úÂëתÒ壺¼âÀ¨ºÅµÈ¶¼±»×ªÒåÁË£¬Õâ¸ö»áÔö¼Ó·þÎñÆ÷µÄѹÁ¦£»¶øÇÒ£¬Õâ¸ö¸ÄÔìÖ»ÊÇÇ°¶ËµÄäÖȾ£¬·þÎñÆ÷ÒÀ¾ÉÊÇÒ»´Î¼ÆËãËùÓеÄÊý¾Ý£¬Êä³öËùÓеÄÊý¾Ý£¬ÕâÒ»µãûÓеõ½Ìá¸ß¡£

Ò»°ãÀ´Ëµ£¬Ê¹Óö¼ÊǺó¶ËÆ´½Ó³É html ×Ö·û´®£¬È»ºóÈûÈë textarea ±êÇ©ÖУ¬Í¸øÇ°¶Ë¡£

demo

Èç¹ûÒª×öÒ»¸öÍêÕûµÄ BigRender demo£¬¿ÉÄܱȽϸ´ÔÓ£¬»¹ÒªÉæ¼°µ½ºó¶Ë¡£

֮ǰѧϰ lazyload ʱ×ö¹ýÒ»¸öͼƬµÄÑÓ³Ù¼ÓÔØ demo£¬see ¡£ÒòΪ BigRender ÊÇ lazyload µÄ¼ÓÇ¿°æ£¬ËùÒÔ¼òµ¥µØ×öÁ˸ö BigRender °æ±¾µÄͼƬÑÓ³Ù¼ÓÔØ £¬ÊµÏֵľßÌå´úÂë¿ÉÒÔ check bigrender.js¡£Çó star£¬Çó fork~

ÆäËû

³ýÁËÊ×Ò³²¿·ÖÓÃÁË textarea ×ö BigRender ÓÅ»¯Í⣬ÃÀÍÅ»¹Óõ½ÁË script ±êÇ©×öÓÅ»¯¡£±ÈÈç Õâ¸öÉÌÆ·ÏêÇéÒ³

¸ø script ±êÇ©ÉèÖøö·Ç "text/javascript" µÄ type£¬¿ÉÒÔÏÂÔØÕâ¶Î js£¬µ«²»Ö´ÐУ¬ÕâÖÖ×ö·¨ËÆÔøÏàʶ£¬ÔÚ labjs Öп´µ½¹ý¡£

¸ü¶à¿ÉÒԲο¼ Ç°¶ËÓÅ»¯ÈýÐø£ºÓÃscript´æ·Åhtml´úÂëÀ´¼õÉÙDOM½ÚµãÊý

Read More

posted on

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • Hero Patterns - ¾ÛºÏ¸÷ÖÖ SVG ±³¾°ÎÆÀíËزĵÄÍøÕ¾ - ÃÎÏëÌì¿Õ£¨É½±ßСϪ£©

    Hero Patterns - ¾ÛºÏ¸÷ÖÖ SVG ±³¾°ÎÆÀíËزĵÄÍøÕ¾ - ÃÎÏëÌì¿Õ£¨É½±ß

    2017-05-02 12:00

  • ¡¾react¿ò¼Ü¡¿ÀûÓÃshouldComponentUpdate¹³×Óº¯ÊýÓÅ»¯reactÐÔÄÜÒÔ¼°ÒýÈëimmutable¿âµÄ

    ¡¾react¿ò¼Ü¡¿ÀûÓÃshouldComponentUpdate¹³×Óº¯ÊýÓÅ»¯reactÐÔÄÜÒÔ¼°

    2017-04-16 09:02

  • ASP.NET Core ÍøÕ¾ÔÚDockerÖÐÔËÐÐ - Âþ²½³¤½­

    ASP.NET Core ÍøÕ¾ÔÚDockerÖÐÔËÐÐ - Âþ²½³¤½­

    2017-04-13 12:00

  • C# ³¬¸ßËÙ¸ßÐÔÄÜдÈÕÖ¾ ´úÂ뿪Դ - Emrys5

    C# ³¬¸ßËÙ¸ßÐÔÄÜдÈÕÖ¾ ´úÂ뿪Դ - Emrys5

    2017-04-12 12:10

ÍøÓѵãÆÀ
Í