Skip to main content
Known Participant
January 20, 2010
Question

Minify inline javascript generated by cfform.js and masks.js

  • January 20, 2010
  • 7 replies
  • 2531 views

In an effort to reduce file size, I would like to minify the javascript that is injected, by (what I suspect) is cfform.

js and masks.js.

Is there a way to do this?  I have already compressed the files themselves, but the script that they are inserting into the code on page render is still coming up in all its tabbed, white-spaced, and uncompressed glory.

Any ideas?

Additionally, I would like to be able to specify where the calls to the cfform.js and masks.js files are in the rendered page as well.  Currently, they get placed right after the <head> tag.  It would be nice to be able to make sure they get placed after the link to the css file for the page - as JS files should come after CSS files for maxium optimization (so I've read).

Help with this would be much appreciated!

Thanks.

    This topic has been closed for replies.

    7 replies

    MShetlerAuthor
    Known Participant
    January 25, 2010

    Thanks Adam, I really appreciate your involvment with my post and your attempts to help me out!

    MShetlerAuthor
    Known Participant
    January 25, 2010

    You know, I haven't ever reported a bug, so I used the link you gave me and went through all the questions.  At the end I expected some sort of, "This is your case number" or "See your email for the number" etc., but didn’t get one.

    Because the hosted site is on an CF8 server that is product I selected.  When I revisit the link you provided the only products I can get to come up are CF9.

    I looked around Adobe.com to try and find something that would point me in the right direction, but no luck.

    I know I'm not making my case look too hot by what could be perceived as ineptitude, but hopefully that's not how its coming across.

    Thanks.

    Inspiring
    January 25, 2010

    No, I feel your pain.  They made some change to the system a couple of days ago, and have buggered it up slightly (in that it does not report the issue number, as you are experiencing).  I didn't realise it affected the "general public" too.  I've brought it to their attention.

    --

    Adam

    MShetlerAuthor
    Known Participant
    January 25, 2010

    I must admit I didn't look into your JRun solution for a couple reasons:

    1) I have not done anything like that before, and while that doesn't stop me from taking on challenges (how else do you learn?), my quick google searches didn't produce anything.  I might not have been using the right phrases.

    2) I was assuming, because of my recent history with the hosting provider, that I won't be able to get access to the files and processes needed to make this happen.

    I will try to look into it a little deeper though.

    I also took your advice and opened a ticket through the bug reporting system.

    Thanks!

    Inspiring
    January 25, 2010

    1) I have not done anything like that before, and while that doesn't stop me from taking on challenges (how else do you learn?), my quick google searches didn't produce anything.  I might not have been using the right phrases.

    I'm a bit flat out at present, but i'll have a look-see later on, if I find time.

    I also took your advice and opened a ticket through the bug reporting system.

    What was the issue number?  I'll go and vote for it.

    --

    Adam

    MShetlerAuthor
    Known Participant
    January 25, 2010

    While I do agree that "web consultants" can be a slippery bunch, having dealt with some rather slippery ones myself, in this case there is a bit of validity to trying to find the answer.

    The site in question is on a shared CF server, and provided by an Adobe "hosting partner" per the Adobe website.

    Unfortunately, they do not offer gzip as an option on the shared environment, citing performance issues with their servers - believe me I have been trying to get them to help as much as possible while trying to tackle the optimization of the site.  They have also been unhelpful with Browser caching and a few other optimizations offered up as possibilities by tools such as Google's Page Speed and Yahoo's YSlow.

    Also, while I definitely don't pretend to be an expert on site optimization, I've done a decent amount of research and reading, and I thought that minification before gzipping increased the results to the positive.

    Having not been able to test this case with gzip because of the afore mentioned hosting situation, I can't speak to whether that is the case or not.

    At any rate I appreciate the feedback, but can't say I'm not disappointed that there doesn't seem to be a good fix here.

    Thanks!

    Inspiring
    January 25, 2010

    At any rate I appreciate the feedback, but can't say I'm not disappointed that there doesn't seem to be a good fix here.

    I don't take it at all personally, but I think my suggestion of the filter approach is a good fix.  Minifying the response text - be it JS or simply removing whitespace from the mark-up - is not the job of the code generating the mark-up, it's the job of the transmission mechanism.

    However it'd be good if Adobe actually did it automatically with the CF generates, I guess.

    How about raising an enhancement request:

    http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html

    I'm sure they'll be releasing an updater for CF before too long, and maybe this issue will get some attention.

    --

    Adam

    Inspiring
    January 25, 2010

    One can apply "filters" at JRun level after CF has finished processing a request and generated the response.  You could write a filter to use a regex to extract <script> blocks and perform a minification on them, and poke 'em back into the response text.

    I've got no idea how to do this, btw, I just know that one can.  I looked at it briefly about six years ago, but the requirement to finish the work disappeared, so I left it.

    You should be able to google it up without too much problem though.

    --

    Adam

    Inspiring
    January 25, 2010

    One can apply "filters" at JRun level after CF has finished

    processing a request and generated the response.  You could

    write a filter to use a regex to extract <script>

    blocks and perform a minification on them, and poke 'em back

    into the response text.

    Good thought. A filter sounds more elegant than capturing the html in CF. Still, hardly seems worth the effort.

    Inspiring
    January 25, 2010

    Good thought. A filter sounds more elegant than capturing the html in CF. Still, hardly seems worth the effort.

    Yep.  With HTTP compression, I don't really see how minifying JS really has much relevance.

    I think it's one of those things created by "web consultants" to keep themselves in work.

    --

    Adam

    MShetlerAuthor
    Known Participant
    January 25, 2010

    If that is indeed what is involved then yes, it sounds pretty involved for shaving what is probably less than 1kb of size off the page.

    However, I think what might possibly be more important is where the

    <script type="text/javascript" src="/CFIDE/scripts/cfform.js"></script>
    <script type="text/javascript" src="/CFIDE/scripts/masks.js"></script>

    Files get placed in the HTML when rendered.  I tried calling them myself in a different spot (towards the bottom of the <body>) but that just made them appear twice - once right after the <head> tag and the other where I placed it.

    I have seen over and over again that having the css link before the <script> links is best practice, but it appears that I'm not able to do this if the cfform.js and masks.js are getting placed where they are.

    Any ideas?

    Thanks!

    Inspiring
    January 25, 2010

    I have seen over and over again that having the css link

    before the <script> links is best practice, but it

    appears that I'm not able to do this if the cfform.js and

    masks.js are getting placed where they are.

    Any ideas?

    Not other than what I have mentioned, no. The placement of cfform.js and mask.js is controlled the same way the rest of the code is - by CF.

    Truthfully, I have never cared enough about placement to try anything like this. So do not take my word for it. Look around in the /CFIDE/scripts directory and see what you find. Obviously make a backup before doing any modifications.

    Message was edited by: -==cfSearching==-

    MShetlerAuthor
    Known Participant
    January 25, 2010

    I hate to bump this - but I haven't received much in the way of views and no responses yet.

    Any ideas?

    Even an answer to where CF injects the calls for the scripts files into the HTML would be nice to know.

    Thanks!

    Inspiring
    January 25, 2010

    I could be wrong, but I think you are in for a tough, and possibly futile, battle.

    If you take a look at the /CFIDE/scripts directories, some of the code appears to be generated via xsl, which is a nasty beast. Not to mention some of it must be controlled by the internals of CF (ie java classes) which you cannot modify. So my guess is it would take a lot of work to do what you have in mind.

    A crude approach might be to capture the generated HTML, modify it, then send it on to the browser. But, that is also involved. It hardly seems worth the hassle to me.