2
votes

Google PageSpeedInsights flags Base.js as unused Javascript in my report. It's pretty substantial at 487kb. Appears to come from including the Youtube player iframe api. Is this file needed and if so, does anyone know why it is being flagged as unused JS in the report?

Iframe API: https://developers.google.com/youtube/iframe_api_reference

Large file that gets flagged on PageSpeedInsights as unused JS: https://www.youtube.com/s/player/c88a8657/player_ias.vflset/en_US/base.js

2

2 Answers

2
votes

If a script is listed under the "Remove Unused Javascript" tab, it doesn't mean the entire script is unused, it means a certain amount of the script's code isn't doing anything on the page.

The algorithm for finding unused code isn't perfect either, I often see scripts that aren't used at all on a page having some sort amount of used code according to google.

The "Remove Unused Javascript" should really be taken with a pinch of salt, and in cases of plugins, like youtube's API, it should be ignored since you can't edit a external API to be more efficient.

In your case, the file is very much needed if your using an embedded Youtube video. If you want to optmize how you load your Youtube video, consider lazyloading it.

-1
votes

I have been looking for 2 days to find a way to download YouTube videos, and I found out that this file is really important, because it loads all video/audio files:

enter image description here