Skip to content

Conversation

@mr21
Copy link
Contributor

@mr21 mr21 commented Jun 14, 2015

Hi,

I saw few bytes to save after reading #2341, but I didn't change the logic.

@markelog
Copy link
Member

Actually, i see only -7 bytes between 8e111df...569123 i really dislike those return ... && ... || makes the logic vague and more complex, especially when we have so much divergence with browsers behaviour.

This is why i specifically didn't used any tricks to make it smaller. If it was 35 bytes it could be a close call though, but it seems 7 bytes not worth it

@arthurvr
Copy link
Member

Actually, i see only -7 bytes between 8e111df...569123 i really dislike those return ... && ... || makes the logic vague and more complex, especially when we have so much divergence with browsers behaviour.

+1. I prefer to keep code more readable and less complex, even if you're able to save a few bytes. 7 bytes isn't worth it IMHO.

@mr21
Copy link
Contributor Author

mr21 commented Jun 15, 2015

@markelog, How did you compare the size? Me, I count how many caracteres there are in the jquery.min.js before and after my change. Do I have to do something more than just start grunt?

So, the main gain is not the return, it's the double of ownerDocument.defaultView.getComputedStyle(e).

@AurelioDeRosa
Copy link
Member

I think that @markelog is comparing the gzipped version while you're comparing the minified-only version.

@mr21
Copy link
Contributor Author

mr21 commented Jun 15, 2015

@AurelioDeRosa, thanks I thought the minified version was also the gzipped version...
I was not informed of the compression for the file transfert in webserver Oo

I did that version because I saw many return with ternary in the code, etc.
I rewrote my change (the minified version doesn't change, it detects the pattern).

@mr21 mr21 changed the title CSS: save 35 bytes on the getStyles function CSS: save 7 bytes on the getStyles function Jun 15, 2015
@staabm
Copy link
Contributor

staabm commented Jun 15, 2015

there is a grunt task to compare the size diff:
https://github.com/jquery/jquery/blob/master/Gruntfile.js#L22

@markelog
Copy link
Member

I did that version because I saw many return with ternary in the code, etc.

Yeah, i'm usually advocating against that style if there is a better way. And yes, we usually care only about gzipped size.

Now it looks much better, so if no one objects and test would run smoothly i will land this

@mgol
Copy link
Member

mgol commented Jun 15, 2015

LGTM.

@arthurvr
Copy link
Member

👍

@mgol
Copy link
Member

mgol commented Jun 15, 2015

@mr21 If you run grunt you'll see the summary at the end:

Running "compare_size:files" (compare_size) task
   raw     gz Sizes                                                            
254280  75219 dist/jquery.js                                                   
 84215  29307 dist/jquery.min.js                                               

   raw     gz Compared to master @ 8e111df641cca3e1b75b31a1971bfc89014b4ded    
  +223    +62 dist/jquery.js                                                   
   +58    +40 dist/jquery.min.js                                               

You're interested in the gz min number compared to master, in this example it's +40 bytes.

@mr21
Copy link
Contributor Author

mr21 commented Jun 15, 2015

@mzgol, so simple.
My grunt is not perfectly installed (i'm on Windows).
Now I see that every time... thanks for your help, I will see what I have to do :)

~/GitHub/jquery>grunt
>> Local Npm module "grunt-babel" not found. Is it installed?

Running "build:all:*" (build) task
>> File 'dist/jquery.js' created.

Running "jsonlint:pkg" (jsonlint) task
>> 1 file lint free.

Running "jshint:all" (jshint) task
>> 137 files lint free.

Running "jshint:dist" (jshint) task
>> 1 file lint free.

Running "jscs:src" (jscs) task
>> 90 files without code style errors.

Running "jscs:gruntfile" (jscs) task
>> 1 files without code style errors.

Running "jscs:test" (jscs) task
>> 1 files without code style errors.

Running "jscs:release" (jscs) task
>> 1 files without code style errors.

Running "jscs:tasks" (jscs) task
>> 7 files without code style errors.

Running "uglify:all" (uglify) task
>> 1 sourcemap created.
>> 1 file created.

Running "remove_map_comment" task

Running "dist:*" (dist) task
Warning: Task "babel:nodeSmokeTests" not found. Use --force to continue.

Aborted due to warnings.

@mgol mgol closed this in 3a0d582 Jun 25, 2015
@mgol mgol changed the title CSS: save 7 bytes on the getStyles function CSS: save 6 bytes on the getStyles function Jun 25, 2015
mgol pushed a commit that referenced this pull request Jun 25, 2015
@mgol
Copy link
Member

mgol commented Jun 25, 2015

Landed, thanks! In the end, it saved 6 bytes on master (3a0d582) & 0 on compat (bf282ea) but is still worthy due to making the code more readable.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

7 participants