WordPress.org

Make WordPress Core

Changeset 6482


Ignore:
Timestamp:
12/24/07 07:08:37 (7 years ago)
Author:
matt
Message:

A better addLoadEvent which kicks off when the DOM is ready instead onLoad, which kicks off after images finish. Code from Dean Edwards, Mathias Miller, John Resig, Jesse Skinner. Should speed up front-end execution.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-header.php

    r6468 r6482  
    2121<script type="text/javascript"> 
    2222//<![CDATA[ 
    23 function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}} 
    24 //]]> 
     23addLoadEvent=(function(){var e=[],t,s,n,i,o,d=document,w=window,r='readyState',c='onreadystatechange',x=function(){n=1;clearInterval(t);while(i=e.shift())i();if(s)s[c]=''};return function(f){if(n)return f();if(!e[0]){d.addEventListener&&d.addEventListener("DOMContentLoaded",x,false);/*@cc_on@*//*@if(@_win32)d.write("<script id=__ie_onload defer src=//0><\/scr"+"ipt>");s=d.getElementById("__ie_onload");s[c]=function(){s[r]=="complete"&&x()};/*@end@*/if(/WebKit/i.test(navigator.userAgent))t=setInterval(function(){/loaded|complete/.test(d[r])&&x()},10);o=w.onload;w.onload=function(){x();o&&o()}}e.push(f)}})();//]]> 
    2524</script> 
    2625<?php if ( ($parent_file != 'link-manager.php') && ($parent_file != 'options-general.php') ) : ?> 
Note: See TracChangeset for help on using the changeset viewer.