tags:

views:

154

answers:

2

I've been handed a Coldfusion application to support and I noticed that CF is adding script tags to certain pages. It appears these js files are supporting certain CF tags because I can't find any reference to the .js file(s) in .cfm file (or in any subsequent include files). The .js files are popular libraries which can be accessed via a CDN versus serving them from our web server. So my question is:

Can the CF tag or a Coldfusion setting be changed to update the .js url?

+1  A: 

The only .js files that CF should be including are for things like cfform or the cf ajax stuff, and they would be pointing to internal, CF specific .js files. I know the underlying cfajax stuff uses ExtJs, but I would imagine that it's a customized version of it so pointing to an external host would probably cause it to break anyway.

I'm not sure what you're referencing when you mention the "popular libraries". Can you elaborate on that? I doubt you can replace any internal CF .js libraries with an external public library and have your CF code still work.

Henry points out the use of the cfajaximport tag, but according to the docs it's only for local .js files:

"Specifies the URL, relative to the web root, of the directory that contains the client-side script files used by ColdFusion."

Although, it would be interesting to see if a valid url would work.

Eric
Just tested, yes, looks like it would work. :)
Henry
+3  A: 

Using the scriptsrc and cssSrc attributes

The scriptsrc attribute is useful if the JavaScript files are not in the default location. This attribute is required in some hosting environments and configurations that block access to the /CFIDE directory.

The default scriptsrc value is determined by the Default CFFORM ScriptSrc Directory setting on the Server Settings > Settings page of the ColdFusion Administrator. For cfform tags, the tag’s scriptsrc attribute takes precedence over this attribute.

You can use this attribute only if the cfajaximport tag is on a top-level page; that is, a page that the client directly requests. You cannot use it, for example, on a page that is specified in a cfwindow tag source attribute.

When you use the cfajaximport tag with a scriptsrc attribute, the specified directory must have the same structure as the /CFIDE/scripts directory. For example, if you specify scriptsrc="/resources/myScripts", the JavaScript files used by AJAX must be in the /resources/myScripts/ajax directory.

This attribute specifies the folder that contains the ColdFusion client-side files for all subsequent tags on the current page, not just for AJAX-based tags. Therefore, the directory tree must include all ColdFusion client-side files used by those tags. For example, if a cfform tag on the page is in Flash or applet format, include the CF_RunActiveContent.js file in the directory specified by the scriptsrc attribute.

You use the cssSrc attribute to specify the location of the CSS files required by ColdFusion AJAX features. This attribute overrides the scriptsrc/ajax/resources directory for the current page. Therefore, if all pages that use a custom scriptsrc directory also use a custom cssSrc directory, you do not have to include the ColdFusion AJAX CSS files in the scriptsrc directory tree.

Example:

<cfajaximport cssSrc="/collegeApp/application/cssFiles" 
    scriptsrc="/collegeApp/ajaxScripts" 
    tags="cftooltip, cfwindow">

reference: Adobe ColdFusion 9 * cfajaximport

Henry