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

2 bytes shaved for the non-ES6 #2

Open
lazyeasydev opened this issue Jan 26, 2017 · 3 comments
Open

2 bytes shaved for the non-ES6 #2

lazyeasydev opened this issue Jan 26, 2017 · 3 comments

Comments

@lazyeasydev
Copy link

I believe this would work. Bored. So, I obviously I had to use Regex.

Uses the className and splits the classes and the -'s in the same go.
Pops the values on the end in sets of 2.

for(t=document.querySelectorAll`*`,i=t.length;i--;)for(s=t[i].className.split(/[- ]/);s.length;)u=s.pop(),t[i].style[s.pop()]=~~u?u+'px':u

First pass. Might mess around later.

@tomhodgins
Copy link
Owner

Oh that's beautiful! Thank you

@lazyeasydev
Copy link
Author

lazyeasydev commented Jan 27, 2017

Had to sit in the car for 9 hours driving to PAX.....

So here is as small as I got it.

116 chars. 24 chars less.

for(i=0;e=document.querySelectorAll`*`[i++];)for(s=e.className.split(/ |-/);u=s.pop();)e.style[s.pop()]=~~u?u+'px':u

Lol. It's quite a bit uglier.

And i'm pretttttty sure I am done. Lol.

@tomhodgins
Copy link
Owner

tomhodgins commented Jan 27, 2017

⛳                     °                    🏌️

Thanks for the amazing golf :) I can't wait to go through this and see how it works, very impressive!

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