WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Callum Macdonald
    Member
    Posted 5 years ago #

    G'day,

    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";
    </script>
    <style type="text/css">
    .TB_overlayMacFFBGHack {background: url(<URL>macFFBgHack.png) repeat;}
    </style>

    Then take out those lines from the two static files.

    On busy sites, this approach will significantly improve performance.

    Cheers - Callum.

    http://wordpress.org/extend/plugins/thickbox/

Topic Closed

This topic has been closed to new replies.

About this Topic

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