-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
Font Awesome places a strain on CSS selector engine #568
Comments
See the alternate stylesheet in the forked version of the repo here: https://github.com/greim/Font-Awesome/blob/master/css/font-awesome-fast.css Haven't tested yet, but this shows the basic idea. I may use this fork in my own projects, to avoid the above issues. |
+1 This is how jQuery UI does it (with a 'ui-icon' class and 'ui-icon-' sub-classes). This change would take a huge load off the browser. I've just loaded your forked version and it works perfectly. Thank you! |
This is an interesting suggestion. Would also mean people could directly reference the PUA code. And combine this with some other magic, and we might have better usability. Thanks for the heads up. |
Combine this with #589 and we might have a winner. |
+1 for the class="icon icon-remove" approach. I think it would be a good way to help people get more efficient sites. |
Agreed. Tentatively putting this in 4.0, as it would break backward compatibility. |
+1 from me. I personally add the 'icon' class anyway. |
Yeah, I've been hacking each release to do this anyway, so it would be nice not to have to do that. Maybe you could provide two stylesheets to maintain backwards compatibility:
Just a thought. The changes in the CSS file to implement this new style aren't very complex. |
Yep, you can have |
I know it's a little hard to tell, but this is one of the 4.0 milestones. And the prefix will likely be easily customizable, as well. I'm thinking of just using something like A lot of groundwork has been laid in the 3.1.0-wip branch for making these changes very quickly. |
Just my two cents: please either go with your plan to make the prefix customizable or use Glad to see there's already work on this. Thank you! |
Global project search and replace not do it for you? :) |
It might for one or two of them, but 'icon' is a pretty common term... |
I'm against adding a 2nd general class just to turn an element into an icon. Specially with the 4.0 version release and it's plan to use something like this <i class="fontawesome fa-delete"> // kinda too specific and long to write
<i class="fa fa-delete"> // .fa would definitely break a site or two
<i class="fontawesome fontawesome-delete"> // this is definitely way to long to type They all look kinda sily to me, I'd rather replace this: [class^="icon-"]:before, [class*=" icon-"]:before with this: .icon-a:before,
.icon-b:before,
.icon-c:before,
.icon-d:before{
} (generating this with SASS would be a breeze (creating a variables collection (array-like data) and then iterating the array with tl;dr, my suggestion is that we should make the process less painful for the FA users, not the FA developers. |
@varemenos I can play around with the css file size when gzipped to see the difference in size. If that technique can be pulled off without too much overhead in size, it might be ideal. But if it bloats the file size too much, we'll have to find another solution. This is a very good thought to push back on though. Thanks for it. I agree, two classes is worse than one. |
If my calculations are correct, the minified version (with 300ish icon classes) will have about 10KB of extra filesize. |
Does that include gzipping? Everything should be gzipped across the wire, so that's the stat that really matters. |
That only includes minifing the css stylesheet. |
With Bootstrap 3 at release candidate it would be nice to see FA 4 come out soon as well. My view is just get to 4.0 with whatever new selector approach makes sense. Then in 4.1, 4.2 etc get back to adding features/icons. |
@varemenos there are also some hacks here and there, so a common class for icons should be needed E.g: https://github.com/FortAwesome/Font-Awesome/blob/master/less/bootstrap.less#L36
|
@ everyone please express your thoughts about this edit: I like I would go for
<div class="only-red-icons-inside-this-div">
<span class="fontawesome-user"></span> User
<span class="fontawesome-fire"></span> Fire
</div> You can't assign the red color to all icons inside the main div without using universal selectors or explicitly list all of them. Sorry for my English |
@tagliala I agree with your points, and I think they are the same as others above. I have a quick question for you about the common class: What do you think of the |
I would avoid AFAIK Dave want to keep compatibility with BS 2.3.2, so
edit I like |
As suggested earlier, the new pattern could be in a new stylesheet with a different name so that backwards compatibility wouldn't be broken. Anyone adjusting to this new pattern is going to have to update their code regardless, so changing the source for the stylesheet would be a trivial change. If that doesn't happen, I really hope the common class is configurable. |
I think this one is closed via e32be98 |
@davegandy reopen if I'm wrong |
It seems like e32be98 will break backwards compatibility, but I'm glad to see a change in this direction! |
It's more than fine, because it will come in 4.0.0, a new major release. |
Ok. Just thought I'd point that out since it was part of the discussion on this issue. :-) |
in what state is 4.0.0. Just the icons... not in conjunction with various bs components but not expect major issues |
Based on some tests I did in Chrome's CSS profiler, the above selectors put a lot of strain on the browser's CSS engine, which is bad for dynamic sites with animations or other things that depend on smooth reflow. Not so much an issue for static "brochure-style" sites. The reason is it forces substring parsing on all class-bearing elements.
What if FontAwesome had an alternate performance-enhanced stylesheet such that:
Not as pretty in the markup, but should put significantly less strain on the browser for those of us who are running into performance issues with Font Awesome.
The text was updated successfully, but these errors were encountered: