Depracted API usage for Core Web Vitals
-
Hi, in the js script output by the language switcher shortcode, there is an API call that is deprecated by Chrome (Lighthouse report) CSSCustomStateDeprecatedSyntax
Here is an updated js code to use instead:
<script type="application/javascript">
document.addEventListener('DOMContentLoaded', function() {
var trp_ls_shortcodes = document.querySelectorAll('.trp_language_switcher_shortcode .trp-language-switcher');
if (trp_ls_shortcodes.length > 0) {
// Get the last language switcher added
var trp_el = trp_ls_shortcodes[trp_ls_shortcodes.length - 1];
var trp_shortcode_language_item = trp_el.querySelector('.trp-ls-shortcode-language');
if (trp_shortcode_language_item) {
// Get the computed style width to ensure compatibility across different scenarios
var trp_ls_shortcode_width = trp_shortcode_language_item.offsetWidth + 16;
// Set the width explicitly for both elements
trp_shortcode_language_item.style.width = trp_ls_shortcode_width + 'px';
var currentLanguage = trp_el.querySelector('.trp-ls-shortcode-current-language');
if (currentLanguage) {
currentLanguage.style.width = trp_ls_shortcode_width + 'px';
}
// Hide the language item after setting the width
trp_shortcode_language_item.style.display = 'none';
}
}
});
</script>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.