[jQuery] Re: Using taconite to append javascript and stylesheets

2008-10-31 Thread Bob Schellink


Hi Ricardo,

ricardobeat wrote:


This works though: $('head')[0].appendChild($('')[0])


Thanks, that is pretty slick. Much better than the approach I took of tracking scripts by appending place holder tags in head.

Just to summarize, my approach to ensure javascript and stylesheet resources are only loaded once, is to validate against guard functions before appending the resource.

An example guard function:

/*
 * This function checks if the given script already exists in the
 * document head section. It uses the following two rules:
 *
 * External scripts are checked against their 'src' attribute.
 * Inline scripts are checked against their 'id' attribute.
 *
 * @param script is a