Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a tangible performance or readability benefit to using tags versus CFSCRIPT?
    text
    copied!<p>I am using ColdFusion 8 and 9.</p> <p>I was reading some ColdFusion best practices yesterday. I came across a section that advised to always use CFSCRIPT whenever possible. The reasoning was that each CFSET is a separate request and needs to be opened and closed by the server (or something to that effect). Since CFSCRIPT is handled as a single block of code, only one open and close is necessary, thereby taking less time for the server process. This advice was given explicitly for ColdFusion 5.</p> <p>I am wondering if this advice holds true today, almost a decade later. Personally, I use CFSCRIPT 99% of the time. I do, however, work with people who use only tags. In a project that I am working on, I encountered this code within a function:</p> <pre><code>&lt;cfset LOCAL.TrackingInfo = structnew()&gt; &lt;cfset LOCAL.TrackingInfo.referral = CGI.HTTP_REFERER&gt; &lt;cfset LOCAL.TrackingInfo.ipaddress = CGI.REMOTE_ADDR&gt; &lt;cfset LOCAL.TrackingInfo.useragent = CGI.HTTP_USER_AGENT&gt; &lt;cfset LOCAL.TrackingInfo.querystring = CGI.QUERY_STRING&gt; </code></pre> <p>I would modify it to look like this:</p> <pre><code>&lt;cfscript&gt; LOCAL.TrackingInfo = structNew(); LOCAL.TrackingInfo.referral = CGI.HTTP_REFERER; LOCAL.TrackingInfo.ipaddress = CGI.REMOTE_ADDR; LOCAL.TrackingInfo.useragent = CGI.HTTP_USER_AGENT; LOCAL.TrackingInfo.querystring = CGI.QUERY_STRING; &lt;/cfscript&gt; </code></pre> <p>For me, the benefit is readability. And, it's really easy to go back and forth between CFSCRIPT and JavaScript and Java (the little Java that I have done). </p> <p>Is there a tangible readability or performance benefit to using CFSCRIPT? Is there any reason for a non-beginner to continue using CF tags?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload