Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minifyMode "filePackage" #77

Open
ghost opened this issue Apr 4, 2013 · 6 comments
Open

minifyMode "filePackage" #77

ghost opened this issue Apr 4, 2013 · 6 comments
Milestone

Comments

@ghost
Copy link

ghost commented Apr 4, 2013

Maybe I'm missing the obvious, but I'd like to use cfstatic to package files which I have specified via include() into one minified package.
Right now I either get ALL files in the folder with the standard 'package' minifyMode or just the files I specified as single HTTP requests with minifyMode 'file'.
Am I missing how to do this or is this feature not implemented?
Thanks in advance for any help!

@DominicWatson
Copy link
Contributor

Have you tried the "all" minify mode?

I briefly touch on that mode here: http://fusion.dominicwatson.co.uk/2011/09/understanding-the-package-minify-mode-in-cfstatic.html

@DominicWatson
Copy link
Contributor

I've just re-read your comment. What you want is not possible w/ CfStatic. Files are minified and compiled on init() of cfstatic. It does not compile files based on .include() calls, these are only for the logic of which includes to render in the given page request.

The point is that in production, once the files have been compiled once, the engine is not doing any compiling from request to request.

I'm not sure that doing what you asked is a good strategy either - if the combination of static files was different for every page / template, you would make your client have to download any common js / css fresh for every new template hit. You can optimise the client download experience by splitting out your packages into core, shared and template specific code - minimizing the number of non-cached downloads of files that the client must make.

@ghost
Copy link
Author

ghost commented Apr 4, 2013

Ok, thanks for the info ;)

I want to switch from combine.cfc, which was doing what i need (minifying and combining files in the specified order, and then caching them so it doesn't do it on every request), but I had problems with its compression algorithm and some JavaScript not working afterwards (like jQuery UI)...

Right now I'm working on a video site, and I have a different set of CSS&JS Files for the desktop, mobile and embedded iframe version. All of them need jQuery, some have their own files, etc.
So basically I would like to specify the needed files in the according FW/1 layout and then package them into one, as before.

Another nice feature would be an option to include files in the order they were added using the include() function (instead of alphabetically), so one doesn't even have to add any dependency information in the files themselves if they're sure they specified them in the right order. Like a "keepIncludeOrder:true" option.

Where would be the best place in the code to go about integrating these? Would be happy to share the code afterwards if the effort for these isn't too much...

@DominicWatson
Copy link
Contributor

Apologies for the late reply. I think the effort would indeed be too much as it is a complete paradigm shift. While using the .include() method to define the order is, I think, the wrong place to define how these files are packed up - I'm open to other, easier to use, methods to define concatenation and ordering rules.

Perhaps something similar to the dependencies file that just specifies minified file names and a list of files that will go into it (in their given order). You could then work on the same set of source css and js files but with three different instances of CfStatic, each with their own concatenation rules defined in a single file. It might look like:

core.min.js
    /jquery/jquery.1.9.js
    /mobile/core/*.js (order defaulting to alphabetical when wildcards used)
    /etc.

@DominicWatson
Copy link
Contributor

Having more of a think about it the idea of using include() to craft individual minified files might not be such a shift. Perhaps a minifyMode of "on-demand"?

And CfStatic would attempt to create a single minified CSS file and a single minified JS file for each specific include combination? That's the thing that concerns me a little - i.e. can be very easily misused to mean that end users will have to download more than they need to by having multiple minified files that share vasts amount of code, e.g. jQuery.

Perhaps a minifyMode of "on-demand" in combination with an optional extra argument to the .include() method:

cfstatic.include( resource="/core/jquery.js", group="core" );
cfstatic.include( resource="/core/core.js", group="core" );
cfstatic.include( resource="/forms/", group="forms" );

While I like the ditching of the dependency configuration, I kind of don't at the same time as it spreads the logic of ordering of includes throughout the code. Will think on it some more.

@cutterbl
Copy link

cutterbl commented May 8, 2013

Yeah, please don't ditch that dependency file ;)

I do love the idea of specifying a "group" of files that could be combined as one, while still minifying single files that are not part of a group. The challenge then becomes the group's dependencies. Do they also get combined into the group file? What happens if one of your single files also has a dependecy on one of those files? (jQuery being a prime example).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants