Login to download the latest version of Mint and your favorite Pepper, purchase additional licenses, or post in the Forum. Don't have an account? Create one!

In Partnership with Media Temple

Mint Forum

Putting the mint script tag to the bottom of body

Yolk
Minted
Posted on Dec 19, '09 at 09:22 am

Hello,

are there any knwon issues with putting the mint script tag to the bottom of the html-body, instead of putting it into the head.

I could not find any problems while testing this approach, but maybe it is not recommanded?

Thanks for any insights, Sebastian.

Shaun Inman
Mint/Pepper Developer
Posted on Dec 23, '09 at 09:01 am

WIth the Mint include at the bottom of the body, if your HTML files are large someone on a slower connection could navigate away before Mint has a chance to record their visit. I seem to recall there being a problem in older versions of IE if the Mint include was not placed in the <head> element.

In Matt Cutts’ latest video (http://googlewebmastercentral.blogspot … -2009.html), he talks about the speed of a site becoming a factor in search rankings in the future.

So I looked at my site using webpagetest.org, as Matt suggests, and found that getting and executing Mint was responsible for about 20% of the time taken to render a page.

The picture I saw was here: webpagetest.org/results/10/01/21/4EXZ/1 … rfall.png. I’m not sure how long that will remain accessible. The green line indicates the point at which the page is rendered. There are lots of obvious things I can do here like merging and minifying my CSS, losing two unused background images and using mod_deflate but I need to be able to address Mint too.

Note that google-analytics, which I also use, does not appear to impact the speed as it only starts to be accessed after the page has been rendered. If I could move Mint down to the foot of the page, I believe it would be outside the rendering time too.

I take Shaun’s point that “someone on a slower connection could navigate away before Mint has a chance to record their visit” but I’m willing to take that risk. Google Analytics must have the same issue.

Has anyone tried this? Any other known issues?

To summarise my afternoon:

Web page without any attempt to optimise: 1.30s

Web page after minifying and compressing: 0.77s

Web page after moving Mint into the footer: 0.52s

That’s the time taken to start rendering - which seems to be the key objective in terms of user experience.

I’m not going to leave Mint in the footer - at least not until I hear some feedback from other Mint users.

Didn’t work out for us, IE users reported that the site got stuck at loading the mint include (IE7/IE8)

This is a bummer. I also noticed that including the mint file at the top of my page was causing some serious lag.

Google Analytics runs their script 100% at the bottom of the page. Why can’t Mint?

I’ve been trying to solve this too. I’ve tried including the Mint script in a minified javascript file served from Cloudfront. But if I do this, Mint stops recording visitors, unlike Google Analytics, which still works. It makes no difference if the script is placed in the header or the footer.

Leaving all the other javascript in the minified file, with only Mint loading separately, restores the functionality, but at a pretty heavy cost.

See this screenshot showing that the Mint script is the slowest-loading item on the index page tested.

@donaldjenkinds: i wonder if you can attribute that sort of performance to mint. i’m not an expert but i wonder if the performance of mint in your situation has more to do with the server performance. i’m not sure if i’m saying that right or not.

i performed that exact same test on pingdom and i got a total load time of 0.6 seconds for mint. it looks like your results are bordering on 1.8 seconds if i’m reading your screen shot correctly.

@wenwon: yes you are quite correct, they are and it’s very irritating. It’s hosted on a Media Temple gridserver with its own dedicated data container.

Serving the script from a CDN speeds it up considerably, but renders it useless as it then doesn’t record any visits.

What is your server setup?

i’m not technical but i do know the particular installation i tested was on a dedicated server. the client has a decent web hosting company. i’ve seen good times for mint in shared environments too.

good luck with your set up..

You must be logged in to reply. Login above or create an account