-
Notifications
You must be signed in to change notification settings - Fork 324
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
New property optimizer (3rd attempt) #249
Conversation
Wow, you did alot of work, looks like you created a v3 rewrite! Well commented also, though you may be flogged publicly for using w3schools & not MDN or CSS-Tricks ;) Might be better to remove those schooling references; makes too much visual noise in the code, bandwidth, & I would hope devs know how to use a search engine. I'll have to test later. |
+1 to getting rid of w3schools references |
@tomByrer, @GoalSmashers Yeah, I know... http://www.w3fools.com/ I forgot to remove the w3schools links, and looking at the code again, seems I also forgot to remove some TODO comments. Unfortunately, most of the people don't know how to use a search engine, so I'd prefer to have some links anyway, maybe to a more appropriate place. Is MDN okay to link to? @tomByrer I have added tests for Btw, this is not really a rewrite. It's still the same concept, only a bit more complicated because now it doesn't forget about what was a shorthand in the original input and what wasn't. So you can think of it as several iterations over the previous code, but all squashed into a single commit. |
One more thing: the code could be organized better. Do you think it's a good idea to put some of the functionality into separate files? |
1200 lines is indeed a bit too much. Feel free to iterate over it if you have spare time and it's doable.
|
Perhaps in the WiKi. Links in code are usually to odd bug reports or unusual syntax (like rare color codes or a programming trick). Code usually is not a place to teach beginner 'programmers' who don't know what a search engine is. Either way, even though w3schools is now thought to be "more friendly to beginners than existing documentation sites", MDN, the actual w3c specs, css-tricks, & sometimes StackOverflow are considered more credible. You could make a blog post explaining what you did, & teach/link CSS & JS you used. Could get you upvoted on Reddit & HN.
Yea, aside from I suspect Lo-Dash, most code is split up if it goes over a few pages long. Perhaps split out the longer functions if they make sense alone? Just please don't split into 30 files with 6 lines each; I hate reading those repos. You're doing great stuff @Venemo ! |
Thanks for the compliments! I'll split some of the stuff into multiple modules, the code will be a lot more readable / understandable. About links: you've convinced me, I'll just remove them. |
Welcome :) BTW, I think your code is understandable now. Smaller chunks are usually easier to manage & mentally process. |
Yes, that's what I meant. Splitting into multiple modules usually also helps with maintainability for the same reasons it helps to more easily grasp the code mentally. |
Okay, I think I'm done :) |
@@ -232,14 +233,35 @@ module.exports = function Optimizer(compatibility) { | |||
return flat.join(';'); | |||
}; | |||
|
|||
var p = require('./processable'); | |||
var overrideCompactor = require('./override-compactor'); | |||
var shorthandCompactor = require('./shorthand-compactor'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put all requires on top.
Most of the comments are regarding:
But in general awesome work! 💯 |
@GoalSmashers While some of the things you do may be standard for a majority of JS devs, some are not. Perhaps it is best to educate via a style guide, since it seems jsHint won't catch everything? Plus, there are many like me who are willing to learn new best practices, like your checking values via an array & indexOf. |
@GoalSmashers @tomByrer Thanks for the thorough review! I can implement the suggestions later today. |
Some personal notes:
Anyway, all the asked changes are implemented. |
@GoalSmashers Is there anything left before you can merge the PR? |
Thanks for the fancy formatting @GoalSmashers
Actually does not matter anymore except in IE, so I guess it is already JIT optimized, at least in tight, repeated loops?
"TIE fighter" is funny. I thought that was the standard, so I tweaked my Notepad++ editor to make those loops easier to find: |
@GoalSmashers Okay! Btw, no disrespect meant for the project conventions! :) |
👍 no worries! |
New, shiny property optimizer.
congrats @Venemo |
Thanks @tomByrer it wasn't easy :) If you have any feedback about the stuff, I'm always interested to hear about you! :) |
(Third attempt.)
This pull request contains a new property optimizer which can perform advanced optimalizations on a CSS selector body. It fixes the following issues: #173, #134, #168, #164, #184, #190, #210
Changes since the previous pull request:
Remaining work: