-
Notifications
You must be signed in to change notification settings - Fork 3
Shapes: js not needed #38
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
base: master
Are you sure you want to change the base?
Conversation
enzy
left a comment
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.
I would prefer a sort of a feature detection approach instead. Import and execute when the primary method fails.
There were also other reasons (other than IE) not to use direct path but I can't remember it now.
|
Same here, however, there isn't a way how to feature detect AFAIK. Delayed import for IE only for a few lines of code is a bit overkill. I've tested Chrome, Safari, Firefox, Edge, IE. All seem to work consistently. |
JirkaVebr
left a comment
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.
I completely agree with @enzy that a feature detection based approach would have been preferable but much like @onset, I cannot think of any. 🙁 Can you, @enzy?
Also, now that shapes are being downloaded as an actual image, why don't we add something like <link rel="preload" as="image" href="/assets/shapes.svg"> (or whatever the appropriate value for as is)? I'd say that being able to start downloading early is the just about the main benefit of and motivation for this change so why not go even further? 🙂
Preloading is overoptimization in this case. Hard maintainability is not worth it. Browser can start downloading with first discovered shape in HTML. That can be a logo in header close to head tag where |
As in it would make the site too fast? What do you mean by that?
You're already inlining script.
initComponents = [
{ name: 'ShapesIE', data: { url: '#{assetPath}/sprites/shapes.svg' } }
]into - const shapesUrl = `${assetPath}/sprites/shapes.svg`
link(rel='preload', as='image', href=shapesUrl)
script.
initComponents = [
{ name: 'ShapesIE', data: { url: '#{shapesUrl}' } }
]does not really incur any maintainability overheads. Now there may be perfectly legitimate reasons not to preload the sprite but I'd say the maintainability aspect you mention is not one of them. |
Nearly same speed for the cost of harder maintainability.
I'm not happy about it. With IE dead there will be one occurrence only. Meanwhile, two occurrences are less than three. Keep in mind that Maintainability is not the main question. What will |
0ce5a2b to
3e303cb
Compare
A. It was the Microsoft Edge, which works now ✔️ B. And the more important problem I can see: ❌
/* This won't work either way,
because it crosses a shadow DOM boundary */
.icon-1 /* ~shadow~ */ .path-1 {
fill: yellow;
} |
enzy
left a comment
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.
Extract Failing build hotfix outside of this PR please and update it to the latest version (3.1.0 atm). Thank you.
I didn't know that you can do this with shadow dom. Do we need to support this use case? Shapes are appropriate for simple icons anyway. |
I'm ready to drop the commit after some fixes master. I don't have resources to migrate whole project. :( |
Maybe an onload handler would be the way how to detect un/successful attempt. Give it some timeout and inject sprites if load hasn't happened yet. From IE docs:
|
Okay, prepared #39 for this.
I can think of one example: animating of manGoweb logo would not be possible this way. But I agree that these special cases could use direct inline svg. |
|
🔝 Thank you. |
So, are we ok with dropping the support of more complex cases since there are other ways to achieve the same like inlining or splitting a shape into two? |
3e303cb to
7232d8d
Compare
- faster, better caching
7232d8d to
91de88c
Compare
| use(xlink:href=`${assetPath}/sprites/shapes.svg#shape-${name}`) | ||
|
|
||
| //- IE fallback | ||
| use(xlink:href=`#shape-${name}`) |
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.
The polyfill code should handle this case (replace all occurences of en external resource to local one) and it should not be included in the HTML twice.
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.
- This way the code can be easily used in lazy loaded html content.
- IE is very bad at handling high JavaScript load. Scanning a whole page can do unnecessary harm during the page load while other work needs to be done too.
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.
@enzy What do you think? Is the double use justified?
|
@JirkaVebr Is the |
Nové nastavení je rychlejší, protože spuštění stažení shapes nečeká na vykonání javascriptu a zároveň dává více informací browseru o tom, co jsou shapes za typ souboru, takže je může lépe cachovat.
(IE celé url v
xlink:hrefnepodporuje, takže pro něj se dál používají staré shapes na základě detekce podle user agentu.)