press icon indicating copy to clipboard operation
press copied to clipboard

allow multiple chunks of compressed script?

Open sauravshah opened this issue 12 years ago • 11 comments

I want to combine 2-3 different scripts into one file and the rest into another. Does not seem possible with press right now and I seem to end up with one monolithic js file.

sauravshah avatar May 17 '12 07:05 sauravshah

It sounds like maybe the greenscript plugin would be better for your needs?

dirkmc avatar May 17 '12 12:05 dirkmc

Does greenscript allow this? Greenscript is too bulky for my use though - too many features that I don't really need and the syntax is complicated enough to cause issues.

sauravshah avatar May 17 '12 12:05 sauravshah

I haven't looked at it for a while, you'd need to check the documentation to see if it's possible. Press is designed to be as simple as possible; at present you can create individually compressed files and a single aggregate file, but you can't divide files into groups to be aggregated.

dirkmc avatar May 17 '12 12:05 dirkmc

It would be great to add this - for example, just add a 'key' parameter to #{press.script} which specifies which group the file is added to.

This would be very helpful in my case where i have ~20 common JS files and then 1-2 specific files per-screen. Without the groups the initial 20 will have to be re-downloaded once for each page, negating a lot of the speed benefit gained by using press.

cmicali avatar Sep 15 '12 12:09 cmicali

Yeah I see what you're saying, let me think about the best solution to that problem

dirkmc avatar Sep 15 '12 13:09 dirkmc

Thanks! I did re-read the docs and noticed it sounds like the generated filenames are based off of the target URL, so for this to work completely maybe that would also have to change to only reflect the files being combined - that way if two pages referenced the same set of JS not only would the press backend use it's cache but the browser cache could work too because the generated filename wouldn't change.

Either way, great work on this module - it's as easy to use as the LESS one (drop-in and it just works) and vastly simpler than greenscript.

cmicali avatar Sep 15 '12 13:09 cmicali

Actually have you tried adding the files using #{press.single-script 'file.js' /}? You may find that it's actually faster than having the files aggregated into groups, because the browser will download them in parallel (it will cache them so they won't be re-downloaded for each page)

dirkmc avatar Sep 15 '12 13:09 dirkmc

That's what I'm doing now - seems fine if the # of page-specific files stays low.

cmicali avatar Sep 15 '12 13:09 cmicali

Ok great. The idea with press was to try to make it as simple as possible, with nothing for the user to really think about, just change the tag name and it should do everything automatically for you. That's why I'd prefer not to introduce any complicating features if possible.

dirkmc avatar Sep 15 '12 13:09 dirkmc

Yeah, totally understand, and that's one of the things that makes press great.

I'll see if I can get any performance #s when we move this to production to gauge if there is a compelling enough reason to consider this.

cmicali avatar Sep 15 '12 13:09 cmicali

Cool, let me know what you find

dirkmc avatar Sep 15 '12 13:09 dirkmc