We are using CFStatic but it is becoming less usef...
# cfml-general
t
We are using CFStatic but it is becoming less useful for JavaScript as YUI does not, and is unlikely to support ECMA6+. It looks like it would be reasonably straightforward to move to google closure but before I do has anybody already done it (or something similar) trying not to reinvent the wheel and all that?
e
So instead of rewriting your javascript or contributing to an open-source project, you're looking at rewriting part or the whole of the application in a new language, correct? To me, it seems ultra inefficient to rewrite a complete application in whole or in part based on the fear that an open-source project may or may not support something years out in the making. that adds to the technical cost of rewriting your code base is not the best course of action. I have found that turning your Javascript and CSS into vanilla Javascript and standard CSS output at the request or on application startup is far more flexible and future-proof. You can either cache or save the result as needed, and you end up with an application that is more modern, more secure, and more adaptive.
t
@Evil Ware I don't think you quite understand the question. Google closure compiler optimizes javascript from their blurb https://developers.google.com/closure/compiler
it compiles from JavaScript to better JavaScript
. CFStatic uses YUICompressor to achieve this but it does not support modern JavaScript so you cant use string templates, arrow functions or optional chaining (?.), the list goes on. So my question is has anyone already written a wrapper for the closure compiler which would allow us to use cfstatic with modern javascript.
If not I will, I have already taken a fork of cfstatic for this very purpose and will of course offer a PR if I do the work
e
the sunset per Google on their own tool is 2024, https://github.com/google/closure-library , and I fully admit I do not know what you ultimately are trying to do. My suggestion, as every fancy addon framework usually needs updates or eventually expires, is to keep it simple. Lets say for example, I need a hello world person name, but I need it in Javascript vs just a string tag, I have a helloworld.cfm, which outputs on-screen script for that, and its nearly identical as "hello.world.js" save for now I can add security and other things before the page is ever processed.
t
there is nothing new or fancy about it it is simply compressing and optimizing the javascript to reduce the time it takes to get the DOM loaded this is technology that has been in use in various forms for 12-15 years. All I am trying to do is to use the vanilla javascript available in modern browsers in our existing CF architecture
s
I personally would look at CDN delivery, even the free version of Cloudflare gives you some optimizations.
e
I would benchmark your code, as in most cases, rendering the javascript with the rest of the page and compressing with standard methods is as fast, if not faster, than having a page open up multiple connections to grab all the resources needed to render the page. Coldfusion has cfcacge, cfsupresswhitspace, and the ability to conditionally take actions at each step of the reading of the content. Cfsupresswhitespace will remove all the extra space in the output. Cfache for further optimization, and if you really want, you could even complete the cfpages for a few extra bits of process savings. I get that you want to make it load faster, but look reducing the amount of data you are delivering and how many times the browser has open a connection to get it.
t
@Evil Ware you really do have no idea about what I am talking about do you I am using cfstatic to compile and merge scripts into single files and in the process optimizing them so they perform more efficiently and reduce network traffic
s
QuicCloud and other CDN can do this nowawdays 😉
t
supress whitespace prevents cf spitting out white space when using tags, if you where using CF 9+ you would be using cfscript that does not emit whitspace by default
e
I guess I missed the whole chapter on what is a dom object and node according to javascript.
t
@spils we deliver through a CDN and across clobal caches
s
Hmmm, my CDN concatenates, minifies, CSS,HTML JS including inline stuff.
e
I work with tools, and guidelines written back when Men were Men, books were on paper, and dinosaurs were pets.
t
I published my first website for the EU in 1998 just remember every day is a school day and you will do fine
@spills we are combining modules to generate numerous sites each with differing requirements it is far easier for us to ship it prebuilt and tested
s
That is where Webpack or similar build tools come into play IMO.
If your JS, CSS is not inline no problems.
e
I find myself working with some things that are nearly as old as your first coding experience, and that is in the works of being brought up to, the mid-early 2010s in technology. you are going about the same thing, just with a different technology to do it, for the same result
t
Maven and gradle rather than webpack
not my first coding experience first website
s
Maven and Gradle work too, I see that a lot on Kotlin projects.
c
We used cfstatic a few years ago and it seemed a good idea at the time to have the CF server automatically handle asset compression etc. But rather than consume server resources for that we switched to locally pre-run Gulp/Node.js modules which do all the work before deploying to the server.
t
turns out it wasn't a huge effort need to make the options a bit more configurable but I have an alpha prototype
a
@Evil Ware I appreciate that you started off trying to help, but as you don't have familiarity with cfstatic then it was probably best to bow out at that point instead of the less than helpful subsequent responses. This slack should be a welcoming environment to all.