Change Coldfusion tags to leverage CDN hosted javascript libraries


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?

Best Solution

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.


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

reference: Adobe ColdFusion 9 * cfajaximport

Related Question