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

Dramatic performance difference between blade component and blade helper #190

Closed
MaxGiting opened this issue Mar 31, 2022 · 8 comments
Closed
Labels

Comments

@MaxGiting
Copy link

MaxGiting commented Mar 31, 2022

There is a huge speed difference depending on which method you use to include an icon using this package.
The two methods I have checked are:

  • Blade Component <x-heroicon-o-arrow-right/>
  • Blade Helper @svg('hero icon-o-arrow-up')

Using the "helper method" is on average 10 times faster to render than using the "component method".

Screenshot 2022-03-31 at 13 59 17

The speed differences aren't much when loading a single icon. However on my website I have a page that lists 80 products per page, with each one having 3 icons. Here it makes sense for me to use @svg as the load time quickly adds up.

Why is using @svg so much faster than <x-heroicon-xxxxx/>?

I have created a sample repo so anyone can easily run the tests for themselves.
https://github.com/MaxGiting/blade-ui-performance

To get the sample repo to work you will need to:

  • clone repo
  • run composer install
  • php artisan icons:cache
  • artisan serve and visit the homepage
@driesvints
Copy link
Member

Hey @MaxGiting, I think you might have missed the caching section here? https://github.com/blade-ui-kit/blade-icons#caching

@MaxGiting
Copy link
Author

@driesvints Thanks for the quick reply! I should have mentioned it in the original issue. I have caching turned on and still see the time difference.

@driesvints
Copy link
Member

@MaxGiting that's very odd. I'll try out your repo as soon as I find some time.

@driesvints driesvints reopened this Mar 31, 2022
@driesvints driesvints added the bug label Mar 31, 2022
@MaxGiting
Copy link
Author

@driesvints thank you. I have simplified the original issue as caching removed the differences on 1st and subsequent page loads. But yes the difference between blade component and @svg still exists.

@driesvints
Copy link
Member

I managed to reproduce this with your repo @MaxGiting, thank you. However, I did not figure out the root cause of this even though with @JayBizzle indications.

I have to say, that I find the current differences in speed to not be overly dramatic. I use Blade Icons on several projects, and haven't experienced much slowness after we implemented icon caching. Therefor, I won't be taking any action here right now. However, should anyone find the root cause of this, I'd very much appreciate a PR. Otherwise, if this is really a concern for you, I suggest to use the svg helper or directives for now.

Thanks

@Erulezz
Copy link

Erulezz commented Apr 20, 2022

I experienced the same when using the components. Even with caching, requests where around 130 ms slower with the font awesome icons. Disabled components and switched to the svg helper and the difference was really noticeable.

Am I correct in that when using the svg helper it has no impact on performance? Since blade views are created and cached in production?

Thanks for this package @driesvints 👍

@driesvints
Copy link
Member

Am I correct in that when using the svg helper it has no impact on performance? Since blade views are created and cached in production?

Not entirely sure if it's "no impact" but it's far less than components apparently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants