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

[Documentation] Icon page and search extremely slow and laggy in Safari browsers - improvement possible? #1122

Closed
oliveratgithub opened this issue Jan 10, 2023 · 9 comments
Labels
good first issue This bug or task is a good first issue for new contributors. help wanted Ready for a contributor to tackle.

Comments

@oliveratgithub
Copy link

oliveratgithub commented Jan 10, 2023

The SL Icon doc page is extremely laggy to the point, that the search is almost non responsive / hard to use, on Safari Webbrowsers - particularly macOS Ventura and iOS (16).

Is it possible to somewhat improve this doc's page, to make it more snappy again? In 2.0.0-beta70+ it used to be much faster, but a short load time lag was already present. Alas not as bad as since 2.0.0-beta87 incl. beta88.

@claviska claviska added help wanted Ready for a contributor to tackle. good first issue This bug or task is a good first issue for new contributors. labels Jan 10, 2023
@claviska
Copy link
Member

Hmm, I'm not seeing a lag except a slight delay while the sprite loads (and the sprite was added to avoid thousands of HTTP requests for icons). Is there any chance you can help me find the culprit?

If anyone else can replicate this, I'm open to a PR. However, I really want to keep the icon search since a lot of people seem to use it.

@oliveratgithub
Copy link
Author

oliveratgithub commented Jan 11, 2023

However, I really want to keep the icon search since a lot of people seem to use it.

Oh yeah, absolutely needed!


Quick check on Safari Mobile indicates long loading times for the svg icon resources; up to 12 seconds:

image

image

@oliveratgithub
Copy link
Author

An online Lighthouse Tests seems to confirm my observations, even on the Chrome Mobile browser:

https://www.webpagetest.org/result/230111_AiDcCX_FVF/

@claviska
Copy link
Member

Quick check on Safari Mobile indicates long loading times for the svg icon resources; up to 12 seconds

These are already deferred, though. Not sure how to "fix" it without gaming Lighthouse, which also won't solve the problem.

Any suggestions?

@oliveratgithub
Copy link
Author

I had some time to look into this again today, and found some hints – but unsure how to interprete these results or if this points into the right/a helpful direction.

Used the Safari 16.3 built-in Timeline recording on a fresh, uncached page load of shoelace.style/components/icon.

Page load over 2.13 Gigabyte (!) of data?

(also refer to below "sprite.svg")

Screenshot 2023-01-30 at 22 48 54

sprite.svg

  • Page seems to load dozens of "sprite.svg" resources, each of 1.09 MB in size -> causing lots and lots of Network requests + CPU usage over the course of about 20 seconds.

Screenshot 2023-01-30 at 22 36 50

Styles Recalculation

  • the event Styles Recalculation in `chunk.CPROBC4U.js (line 249) seems to take quite some time (>7 seconds, each)
  • the corresponding line 249 in the chunk JS file is referring to the function shown below: function a2(t2)

Screenshot 2023-01-30 at 22 40 12

Screenshot 2023-01-30 at 22 40 33

@claviska
Copy link
Member

I do see a bit of a lag in Safari that I'd love to track down and improve on, but what you're seeing there is the result of this dev tools option being checked, effectively disabling all caching:

CleanShot 2023-01-31 at 13 13 58@2x

Can you run that again with this box unchecked? Hopefully it provides a more useful result.

@oliveratgithub
Copy link
Author

Can you run that again with this box unchecked? Hopefully it provides a more useful result.

Okay yeah, that does no longer skyrocket the Network requests and resources loaded ^^

I think I spotted the culprit (see below): for me it seems to be caused by the SlTooltip being wrapped around each Icon loaded into the Icon Search?


Here are the most interesting results I spotted when Caching is ENabled:

appendChild connectedCallback()

(from chunk.MVSJC4JT.js which contains // src/components/tooltip/tooltip.tsand var SlTooltip = class extends ShoelaceElement)

Screenshot 2023-01-31 at 22 50 02

Screenshot 2023-01-31 at 22 55 51

Styles Recalculated (8.01 s)

(Layout & Rendering)

Screenshot 2023-01-31 at 22 51 25

@claviska
Copy link
Member

claviska commented Feb 6, 2023

I'm not sure why Safari had so much trouble with this page, but perhaps dumping 1,000+ tooltips into the DOM on page load isn't a good idea. 😅

Fixed in af70d88 by lazily appending tooltips on mouseover. The result should be invisible to the user and is definitely more performant in Safari.

You can preview it here: https://next.shoelace.style/components/icon

@oliveratgithub
Copy link
Author

I'm not sure why Safari had so much trouble with this page, but perhaps dumping 1,000+ tooltips into the DOM on page load isn't a good idea. 😅

Awesome! 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue This bug or task is a good first issue for new contributors. help wanted Ready for a contributor to tackle.
Projects
None yet
Development

No branches or pull requests

2 participants