I am using the below functions in current app to dynamically include JS, CSS when in canvas view.
function JSinclude(script_filename) {
var html_doc = document.getElementsByTagName('head').item(0);
var js = document.createElement('script');
js.setAttribute('language', 'javascript');
js.setAttribute('type', 'text/javascript');
js.setAttribute('src', script_filename);
html_doc.appendChild(js);
return false;
}
function CSSinclude(script_filename)
{
var html_doc = document.getElementsByTagName('head').item(0);
var css = document.createElement('LINK');
css.setAttribute('REL', 'StyleSheet');
css.setAttribute('type', 'text/css');
css.setAttribute('media', 'screen');
css.setAttribute('HREF', script_filename);
html_doc.appendChild(css);
return false;
}
This has notable performance gain in profile view, when lots of apps compete for bandwidth.
Thanks
~@@k@sh
http://aakash-bapna.blogspot.com > Date: Thu, 24 Apr 2008 10:08:16 +0100
> From:
mic...@mahemoff.com> To:
opensoc...@googlegroups.com> Subject: [OpenSocial] Re: Avoiding absolute URLs in JS/CSS includes