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

Make JSqueeze filter work with 1.x and 2.x (namespaced) #698

Merged
merged 1 commit into from
Jan 2, 2015

Conversation

AdamWill
Copy link

@AdamWill AdamWill commented Jan 1, 2015

JSqueeze 2.x just came out, and it's now namespaced. This should let the filter work with both 1.x and 2.x. Obviously it'd also be simple to just make it work with 2.x only if you wanted to go that way.

I thought about adding some helper bits to make it easier to use upstream's default special var regex on 2.x, but thought I'd just keep it simple for now. We could do something like have setSpecialVarRx accept 'true', and have that set the value to JSqueeze::SPECIAL_VAR_PACKER on 2.x.

@nicolas-grekas wdyt?

It'd be good to have this on the stable branches too.

@AdamWill
Copy link
Author

AdamWill commented Jan 1, 2015

(if anyone's watching this, please play Yakity Sax at this point)

// Upstream default for special var is false in 2.x
if (class_exists('\\Patchwork\\JSqueeze')) {
$this->classname = '\\Patchwork\\JSqueeze';
$this->specialVarRx = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should provide the same default I believe if you want 1 vs 2 to be transparent \Patchwork\JSqueeze::SPECIAL_VAR_PACKER in 2.0

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't really sure whether to do that or respect the upstream default for the current jsqueeze. As another idea, maybe make it default false in both cases, as experience seems to have suggested that's the best choice (which is why you changed it upstream in 2.x, right?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false by default in 1 and 2 would be fine for me. As you noticed, the option allows increasing the compression ratio but lets have a safer default

@AdamWill
Copy link
Author

AdamWill commented Jan 2, 2015

@nicolas-grekas how about this version? the global renaming is disabled by default for 1.x and 2.x but you can do setDefaultRx(true) to enable it with the default regex. (haven't tested that bit yet, I will).

edit: looks like it works. Well, it doesn't seem to be safe to use with OC - if I enable the global renaming I get buggy OC behaviour - but it does what it's supposed to do, I think.

Also disables the global var renaming behaviour by default
for both 1.x and 2.x (this seems like the safest choice) but
allows setSpecialVarRx(true) to enable it with the default
regex.
@stof
Copy link
Collaborator

stof commented Jan 2, 2015

Thank you @AdamWill.

@stof stof merged commit 0182f4e into kriswallsmith:master Jan 2, 2015
stof added a commit that referenced this pull request Jan 2, 2015
…dam Williamson)

This PR was merged into the 1.2-dev branch.

Discussion
----------

Make JSqueeze filter work with 1.x and 2.x (namespaced)

JSqueeze 2.x just came out, and it's now namespaced. This should let the filter work with both 1.x and 2.x. Obviously it'd also be simple to just make it work with 2.x only if you wanted to go that way.

I thought about adding some helper bits to make it easier to use upstream's default special var regex on 2.x, but thought I'd just keep it simple for now. We could do something like have `setSpecialVarRx` accept 'true', and have that set the value to `JSqueeze::SPECIAL_VAR_PACKER` on 2.x.

@nicolas-grekas wdyt?

It'd be good to have this on the stable branches too.

Commits
-------

0182f4e Make JSqueeze filter work with 1.x and 2.x (namespaced)
stof added a commit to symfony/assetic-bundle that referenced this pull request Jan 2, 2015
This disables the special var renaming feature of Jsqueeze by default,
matching the change done in kriswallsmith/assetic#698
@AdamWill
Copy link
Author

AdamWill commented Jan 2, 2015

@stof thank you! would it be possible to get it on the 1.2 branch too?

AdamWill added a commit to AdamWill/core that referenced this pull request Jan 9, 2015
The JSMin minifier is non-free. JShrink is free, it's also a
currently-maintained project following good development
practices (though we may wish to switch to JSqueeze soon for
performance reasons; waiting on
kriswallsmith/assetic#698 reaching
upstream Assetic 1.2 for that). This goes along with a 3rdparty
commit that drops mrclay/minify and adds JShrink.
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

Successfully merging this pull request may close these issues.

3 participants