NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP html DOM manipulation

John Campbell jcampbell1 at gmail.com
Wed Aug 10 10:57:35 EDT 2011


> 2) After the entire page is loaded, an onDomReady event is fired which find
> all href links with a rel attribute of lightbox[x] where x is some text.
>  The javascript code will then check to see if there is a thumbnail for the
> image[by checking for the same image name in a subdirectory called thumbs -
> if so, it changes the innerHTML to an img tag pointing to the thumbnail and
> sets the alt attribute for the thumbnail to the original text for the link.

This is a problem.  For javascript to detect if an image exists on the
server, it must do a HTTP request which takes ~100ms.  For PHP to
check if that image exists on the same machine, requires 1 sys call or
about ~0.01ms.  It sounds like you have a bad lightbox implementation.
 The page should already know if the thumbnail exists, and if a
lightbox is possible when the html is sent.



More information about the talk mailing list