Jump to content
TNG Community
Mike Goodstadt

A much faster plugin...

Recommended Posts

Mike Goodstadt

So I was bogged down with a load time of over 8 seconds or more and some frustrating 404s, time outs and much more... Using Firebug and tools.PINGDOM.com I could see that there was significant 'wait' times on the files which were being loaded in the TNG head. This did not occur if accessing TNG directly. I mulled over Server parameters, HTTP requests, file compression, other WP plugins, but none were remiss.

Chatting it through with Heather Feuerhelm of Larlee Genealogy and uniquelyyourshosting.com she suggested reviewing the database setup - I used separate ones for WP and TNG for security and ease of recovery if needed. So I united the WP and TNG databases which reduced the load time by 2 seconds. Good but I wanted more...

I looked again at the files in the TNG head which was being processed by WP-TNG plugin. The difference between them and all other JS or CSS files being loaded in the <head> was that they did not have a full path specified. This meant a trek off to the server to find them, as the WP page is a reconstruct of the original TNG page. These files, therefore do not really reside in the paths "js/" or "css/" relative to the WP page but rather in subfolders of the true TNG path structure.

So I edited the WP-TNG plugin where the function mbtng_buffer_start cleans up the TNG head before wrapping. My aim was to add the full path to all JS and CSS in the TNG head. I added a call to the global variable $tngdomain at line 797 (I am using v6 from the forum):

        global $tng_output, $tng_head, $tng_footer, $tngdomain;
and then these two lines at line 831:
                        $tng_head = str_replace('src="js', 'src="'.trailingslashit($tngdomain).'js', $tng_head);
                        $tng_head = str_replace('href="css', 'href="'.trailingslashit($tngdomain).'css', $tng_head);

This has HALVED the load time down to 3.23 seconds!!! An excellent result.

I recommend trying this and sharing any feedback and the results you get.



Share this post

Link to post
Share on other sites
Haime Croeze


I'm not really a programmer (I do understand programming though). I have on my website (http://www.croeze.net) a combination of tng-plugin and old-fashioned "embedding" of header, page and footer of tng and wp. It is lightning fast AND integrates login! My only issue is that sometimes the code "breaks". Instead of the wp-page (www.croeze.net/gendata) it tries to show www.croeze.net/tng/search-forms.php. Then the page goes haywire and shows the header twice. One click on the genealogy database link in the menu and the start page is shown correctly again. I have not been able to solve this yet though.

Anyhow, thanks a lot for your work, because with this version finally the plugin respects the privacy settings I have on TNG and living are not shown anymore to those coming from my blog.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now