-
Notifications
You must be signed in to change notification settings - Fork 98
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
Fallback script obsolete - remove it #996
Comments
I wonder if we should consider adding |
I just checked and Gutenberg is explicitly selecting the .wp-block-image {
img {
height: auto;
max-width: 100%;
vertical-align: bottom;
box-sizing: border-box;
} This is done commonly in Gutenberg: This is also super common in themes generally: https://wpdirectory.net/search/01HX83JEWYSX880A2CN2W8G5GA This was a big headache for the AMP plugin when we converted |
As we chatted about today, it turns out explicitly targeting an |
@thelovekesh Hey Lovekesh I can pick this up!! |
@Anuj-Rathore24 I recommend waiting to work on this until after @adamsilverstein has finished work in #1176. |
Hey @Anuj-Rathore24 - thanks for offering to work on this! We have added both AVIF and picture element support so this should be good to consider again. One improvement I think we skipped when adding picture element is that the fallback script should only load when Thinking further - since we have picture element support now, I feel this fallback script is less useful now and maybe we should just consider deprecating/removing it - what do you think @westonruter? Is this still needed? when would it be useful? Some comments if we do go ahead with updates here:
Doesn't seem worth the effort to change this!
That makes sense to me
sure
+1 no idea why this was added as query args in te first place. |
@adamsilverstein I agree that the fallback script is obsolete now, given the support for the picture element, but also because WebP is in Baseline being supported by 96%+ of users' browsers, and AVIF being in 2024 Baseline being supported by 93%+ of users' browsers. I think we should go ahead and just remove it. |
I will adjust this ticket make that its intent. |
Hey @Anuj-Rathore24 - quick update - this Issue is now about removing the use of the fallback script from the plugin, do you want to work on that? |
Hey @adamsilverstein, I would love to work on this. Give me some time to go through everything! |
Hey @adamsilverstein @westonruter, I should also remove heredoc string, right? because this is not being used anywhere! performance/plugins/webp-uploads/hooks.php Lines 736 to 769 in 29361ec
|
@Anuj-Rathore24 that's correct! |
Hey @westonruter, I think I made a mistake while analysing the code, can you please correct me if I am wrong. What we want to achieve is to remove fallback.js script from our header which would be added using wp_print_inline_script_tag function. So what I could do is just remove one line, i.e. L-761, and its format specifier from line L-758 while keeping the rest of the function same as it is! performance/plugins/webp-uploads/hooks.php Lines 736 to 769 in 29361ec
I think so, We don't need to remove the heredoc string, as it was modified by Adam in the previous PR. |
@Anuj-Rathore24 I believe you can actually remove that entire |
@westonruter, The function is attached to an action in foreach loop, if I am removing the function I should also remove the whole foreach loop. performance/plugins/webp-uploads/hooks.php Lines 672 to 687 in 29361ec
|
@Anuj-Rathore24 good point, yes! |
See discussion below where we decided we should drop the fallback script, especially since the plugin now supports the
<picture>
element which provides smoother fallback experience, and because WebP is so widely supported.Old description for "Script handling in WebP Uploads can be improved"
Currently an inline script is printed to the page which conditionally loads a
fallback.js
script:performance/modules/images/webp-uploads/hooks.php
Lines 699 to 705 in 11be325
Note how it adds a
data-rest-api
data attribute here. This is then read infallback.js
via:performance/modules/images/webp-uploads/fallback.js
Lines 91 to 93 in 11be325
This value is then used to construct the
script
URL to load:performance/modules/images/webp-uploads/fallback.js
Lines 129 to 137 in 11be325
A couple things here:
fetch()
than to use JSONP?restPath
would be better constructed withURLSearchParams
, or if IE11 compat is really desired, fall back to usingdocument.createElement('a').href
.Also, in that inline script it would be slightly safer if this line used
wp_json_encode()
:performance/modules/images/webp-uploads/hooks.php
Line 683 in 11be325
Like:
Lastly, instead of relying on data attributes on the script tag, the necessary data may make more sense to export into JS via
wp_add_inline_script_tag()
or else a JSONscript
. The reason is that thescript
tag for JS may end up getting concatenated with other scripts, resulting in those attributes getting lost.The text was updated successfully, but these errors were encountered: