Render-Blocking Resources

Created on 20 April 2020, almost 5 years ago
Updated 23 January 2025, 3 months ago

Problem/Motivation

Render-blocking resources

The <script> for brightcove gets loaded inline within the body of the page content. The loading and execution of scripts that are not necessary for the initial page render may be deferred until after the initial render or other critical parts of the page have finished loading.

Currently the script is loaded from: https://git.drupalcode.org/project/brightcove/-/blob/7.x-7.x/brightcove-...

Proposed resolution

The goal is to reduce the impact of the render-blocking JS by deferring the resources by adding async attribute

Script loading can be updated as below

<script async src="//players.brightcove.net/<?php print $account_id; ?>/<?php print $player_id; ?>_<?php print $embed; ?>/index.min.js"></script>

Another option would be to load the JS using drupal_add_js, which can be done in the template_preprocess_brightcove_field_embed

function brightcove_preprocess_brightcove_field_embed(&$variables) {
  $variables['data_usage'] = 'cms:drupal:' . VERSION . ':' . system_get_info('module', 'brightcove')['version'] . ':javascript';

  $script_url = '//players.brightcove.net/' . $variables['account_id'] . '/' .  $variables['player_id'] . '_' . $variables['embed'] . '/index.min.js';
  drupal_add_js($script_url, 'external');
}
πŸ’¬ Support request
Status

Closed: outdated

Version

6.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States sumachaa

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024