Skip to content

Commit

Permalink
Enable native lazy loading by default
Browse files Browse the repository at this point in the history
Closes #89
  • Loading branch information
simonihmig committed Feb 5, 2021
1 parent e0b1b02 commit 89aa535
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions addon/components/responsive-image.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{{/each}}
<img
src={{this.src}}
loading="lazy"
...attributes
/>
</picture>
12 changes: 12 additions & 0 deletions tests/integration/components/responsive-image-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,18 @@ module('Integration: Responsive Image Component', function (hooks) {
);
});

test('it loads lazily by default', async function (assert) {
await render(hbs`<ResponsiveImage @image="assets/images/test.png" />`);
assert.dom('img').hasAttribute('loading', 'lazy');
});

test('it can optionally load eager', async function (assert) {
await render(
hbs`<ResponsiveImage @image="assets/images/test.png" loading="eager" />`
);
assert.dom('img').hasAttribute('loading', 'eager');
});

test('it renders arbitrary HTML attributes', async function (assert) {
await render(
hbs`<ResponsiveImage @image="assets/images/test.png" class="foo" role="button" data-test-image />`
Expand Down

0 comments on commit 89aa535

Please sign in to comment.