Skip to content
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

[SPIKE] Configure iframe-resizer for reduced CPU usage #3028

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/javascripts/components/example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,28 @@ Example.prototype.init = function () {
return
}

var options = {
// Initial resize only, no event listeners
autoResize: false,

// Calculate height from `data-iframe-height` only
heightCalculationMethod: 'taggedElement',

// Calculate height from iframe contents only
resizeFrom: 'child',

// Skip iframe `scrolling` attribute
scrolling: 'omit'
}

// Initialise asap for eager iframes or browsers which don't support lazy loading
if (!('loading' in $module) || $module.loading !== 'lazy') {
return iFrameResize({ scrolling: 'omit' }, $module)
return iFrameResize(options, $module)
}

$module.addEventListener('load', function () {
try {
iFrameResize({ scrolling: 'omit' }, $module)
iFrameResize(options, $module)
} catch (err) {
if (err) {
console.error(err.message)
Expand Down
1 change: 1 addition & 0 deletions views/layouts/layout-example.njk
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
{% block header %}{% endblock %}

{% set bodyClasses = "app-example-page" %}
{% set bodyAttributes = { "data-iframe-height": "" } %}

{% block main %}
<!-- Disable browser validation for any examples that include form elements -->
Expand Down