[Plugin: ThickBox] Use <script> tags instead of str_replace (1 post)

  1. Callum Macdonald
    Posted 7 years ago #


    The way this plugins grabbing the JS files and using str_replace() is inefficient. It means WordPress is loaded once for each request. This makes the web server do *a lot* more work than is necessary.

    Instead, it would be much more efficient to include the files as static JS/CSS files (no PHP parsing). Then, insert a <style> and <script> tag into the WordPress header on every page.

    Insert this at wp_head:

    <script type="text/javascript">
    var tb_pathToImage = "<URL>loadingAnimation.gif";
    <style type="text/css">
    .TB_overlayMacFFBGHack {background: url(<URL>macFFBgHack.png) repeat;}

    Then take out those lines from the two static files.

    On busy sites, this approach will significantly improve performance.

    Cheers - Callum.


Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 7 years ago by Callum Macdonald
  • This topic is not a support question
  • WordPress version: 2.6