Latest Articles:
Committee Members:
Alert Email
Get a short email alert whenever a new entry is published.
Confidential, secure it's piece of cake to keep uptodate.
CFJAVASCRIPT gets a turbo boost
One of the beautiful side benefits of open source is the ability to collate and integrate feedback very quickly. This is probably one of the biggest advantages over commercial software. OpenBD enjoys a 6monthly release cycle (April + October) so when we release our major milestones you can be sure the code has been well baked and tested by the time you build a business around it.
One of the tags that has been given the open source loving treatment has been CFJAVASCRIPT. Released earlier this year it has proven popular to those that are managing lots of Javascript files in their apps. This tags lets you manage your Javascript by optimizing them to make them load and run faster at the browser.
So the usual benefits of minimizing, munging, and heavily caching them all go a long way to help speed up your web application. Instead of downloading multiple javascript files, CFJAVASCRIPT can bring them together as a single unit and force the browser to cache them aggressively.
We've just added a whole host of extras that have been requested by the community:
- Ability to place Javascript code inside the tag instead of specifying external javascript files
- Specify a comma-separated list of javascript files as the SRC='' attribute. Arrays of files still supported
- Include-Only-Once; if you have multiple CFJAVASCRIPT tags, then we make sure you only include a javascript file only once per request. That way the browser won't get two JQuery instances!
- Javascript placement; you can now have the resulting javascript placed at either the position the tag appears, at the HEAD or at the BOTTOM of the HTML body tag
For example, this snippet will place the resulting optimized Javascript reference at the bottom of the page.
<cfset jsFiles = "jquery.js,jtree.js"> <cfjavascript src="#jsfiles#" minimize="true" munge="true" output="body">
Alternatively you can use it to optimize inline code:
<cfjavascript minimize="true" munge="true" output="body">
myClass = {
someStuff : function(){
// do something
}
};
</cfjavascript>
Ready to use from the nightly build. Enjoy.
Comments (6)
Some very nice additions. Looking forward to playing with it a bit more!
This looks great - thanks to everyone for all your work on this and for open bluedragon in general - I just wish all the cf engines would implement this as I hate putting in code which is specific to only one engine.
CFSTYLESHEET tag is already in the engine ready for you to use
that looks like a very nice feature. is there any plan to do the same for css?
Outstanding idea, conceptually. Only negative I have is that "munge" is not a very descriptive attribute name, so it might confuse developers who don't understand it's intention.




That is a very cool and useful feature.