Skip to content

Commit 2a77794

Browse files
authored
Merge pull request #276 from mfranzke/refactor/adapting-script-name
refactor: adapting script name
2 parents 59f5d6c + 7a3bb39 commit 2a77794

29 files changed

+49
-40
lines changed

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,20 @@ You may optionally load via npm or Bower:
6363
Include one of the provided JavaScript files depending on your setup plus the CSS file:
6464

6565
```html
66-
<link rel="stylesheet" href="dist/loading-attribute-polyfill.css" />
67-
<script src="dist/loading-attribute-polyfill.js" async></script>
66+
<link
67+
rel="stylesheet"
68+
href="dist/loading-attribute-polyfill-with-serviceworker.css"
69+
/>
70+
<script
71+
src="dist/loading-attribute-polyfill-with-serviceworker.js"
72+
async
73+
></script>
6874
```
6975

7076
or e.g. within JS
7177

7278
```js
73-
import loadingAttributePolyfill from "node_modules/loading-attribute-polyfill-with-serviceworker/dist/loading-attribute-polyfill.module.js";
79+
import loadingAttributePolyfillWithServiceWorker from "node_modules/loading-attribute-polyfill-with-serviceworker/dist/loading-attribute-polyfill-with-serviceworker.module.js";
7480
```
7581

7682
### Additional information on your image and document (iframe) references
@@ -87,13 +93,13 @@ And please "Avoid lazy-loading images that are in the first visible viewport", c
8793
8894
### Register a Service Worker
8995

90-
Furthermore you would either need to integrate the code out of [loading-attribute-polyfill.sw.js](loading-attribute-polyfill.sw.js) to your existing [Service Worker](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker) or register one by yourself – please keep in mind that it's very important to add the feature detection to the Service Workers URL within the `navigator.serviceWorker.register` methods parameter, as we're transfering that information on the users enviroments capabilities via this way.
96+
Furthermore you would either need to integrate the code out of [loading-attribute-polyfill-with-serviceworker.sw.js](loading-attribute-polyfill-with-serviceworker.sw.js) to your existing [Service Worker](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker) or register one by yourself – please keep in mind that it's very important to add the feature detection to the Service Workers URL within the `navigator.serviceWorker.register` methods parameter, as we're transfering that information on the users enviroments capabilities via this way.
9197

9298
```javascript
9399
if ("serviceWorker" in navigator) {
94100
// Differentiate in between the Service Worker scripts for the different browser capabilities / support
95101
navigator.serviceWorker.register(
96-
"loading-attribute-polyfill.sw.js?loading-images=" +
102+
"loading-attribute-polyfill-with-serviceworker.sw.js?loading-images=" +
97103
("loading" in HTMLImageElement.prototype) +
98104
"&loading-iframes=" +
99105
("loading" in HTMLIFrameElement.prototype)
@@ -174,7 +180,7 @@ if ("serviceWorker" in navigator) {
174180
In case that you're dynamically adding HTML elements within the browser, you could call the following method with an included [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) object, like e.g.:
175181

176182
```JavaScript
177-
loadingAttributePolyfill.prepareElement(
183+
loadingAttributePolyfillWithServiceWorker.prepareElement(
178184
document.querySelector('main [loading="lazy"]')
179185
);
180186
```
@@ -193,22 +199,22 @@ In general we recommend to use the Web Standard of customized built-in elements
193199
```
194200

195201
```javascript
196-
import loadingAttributePolyfill from "loading-attribute-polyfill-with-serviceworker";
202+
import loadingAttributePolyfillWithServiceWorker from "loading-attribute-polyfill-with-serviceworker";
197203

198204
// See https://html.spec.whatwg.org/multipage/indices.html#element-interfaces
199205
// for the list of other DOM interfaces.
200206
class LoadingImages extends HTMLImageElement {
201207
constructor() {
202208
super(); // Always call super() first in the constructor.
203209
// Call for preparing the sample image element included the latest dynamically inserted
204-
loadingAttributePolyfill.prepareElement(this);
210+
loadingAttributePolyfillWithServiceWorker.prepareElement(this);
205211
}
206212
}
207213

208214
customElements.define("loading-image", LoadingImages, { extends: "img" });
209215
```
210216

211-
compare to the code within [demo/loading-attribute-polyfill.custom-builtin-extend.image.js](demo/loading-attribute-polyfill.custom-builtin-extend.image.js) (or [demo/loading-attribute-polyfill.custom-builtin-extend.iframe.js](demo/loading-attribute-polyfill.custom-builtin-extend.iframe.js) for iframe elements).
217+
compare to the code within [demo/loading-attribute-polyfill-with-serviceworker.custom-builtin-extend.image.js](demo/loading-attribute-polyfill-with-serviceworker.custom-builtin-extend.image.js) (or [demo/loading-attribute-polyfill-with-serviceworker.custom-builtin-extend.iframe.js](demo/loading-attribute-polyfill-with-serviceworker.custom-builtin-extend.iframe.js) for iframe elements).
212218

213219
In case that you even also would like to support Safari / WebKit browsers, you'll need a polyfill as this engine doesn't support that part of the Custom Elements standard so far: <https://www.npmjs.com/package/@ungap/custom-elements>
214220

demo/index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@
4848
height: auto;
4949
}
5050
</style>
51-
<link rel="stylesheet" href="../dist/loading-attribute-polyfill.css" />
51+
<link
52+
rel="stylesheet"
53+
href="../dist/loading-attribute-polyfill-with-serviceworker.css"
54+
/>
5255

5356
<!-- Include polyfill for custom elements and builtin extends support -->
5457
<script
@@ -224,7 +227,7 @@ <h2>dynamic images &amp; iframes</h2>
224227
if ("serviceWorker" in navigator) {
225228
// Differentiate in between the Service Worker scripts for the different browser capabilities / support
226229
navigator.serviceWorker.register(
227-
"../loading-attribute-polyfill.sw.js?loading-images=" +
230+
"../loading-attribute-polyfill-with-serviceworker.sw.js?loading-images=" +
228231
("loading" in HTMLImageElement.prototype) +
229232
"&loading-iframes=" +
230233
("loading" in HTMLIFrameElement.prototype)

demo/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ document
4242

4343
// Importing the two files which show how to register these elements as custom elements builtin extends
4444
/* eslint-disable import/no-unassigned-import, import/first */
45-
import './loading-attribute-polyfill.custom-builtin-extend.image.js';
46-
import './loading-attribute-polyfill.custom-builtin-extend.iframe.js';
45+
import './loading-attribute-polyfill-with-serviceworker.custom-builtin-extend.image.js';
46+
import './loading-attribute-polyfill-with-serviceworker.custom-builtin-extend.iframe.js';
4747
/* eslint-enable import/no-unassigned-import, import/first */

demo/loading-attribute-polyfill.custom-builtin-extend.iframe.js renamed to demo/loading-attribute-polyfill-with-serviceworker.custom-builtin-extend.iframe.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import loadingAttributePolyfill from '../dist/loading-attribute-polyfill.module.js';
1+
import loadingAttributePolyfillWithServiceWorker from '../dist/loading-attribute-polyfill-with-serviceworker.module.js';
22

33
// See https://html.spec.whatwg.org/multipage/indices.html#element-interfaces
44
// for the list of other DOM interfaces.
55
class LoadingIframes extends HTMLIFrameElement {
66
constructor() {
77
super(); // Always call super() first in the constructor.
88
// Call for preparing the sample iframe element included the latest dynamically inserted
9-
loadingAttributePolyfill.prepareElement(this);
9+
loadingAttributePolyfillWithServiceWorker.prepareElement(this);
1010
}
1111
}
1212

demo/loading-attribute-polyfill.custom-builtin-extend.image.js renamed to demo/loading-attribute-polyfill-with-serviceworker.custom-builtin-extend.image.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import loadingAttributePolyfill from '../dist/loading-attribute-polyfill.module.js';
1+
import loadingAttributePolyfillWithServiceWorker from '../dist/loading-attribute-polyfill-with-serviceworker.module.js';
22

33
// See https://html.spec.whatwg.org/multipage/indices.html#element-interfaces
44
// for the list of other DOM interfaces.
55
class LoadingImages extends HTMLImageElement {
66
constructor() {
77
super(); // Always call super() first in the constructor.
88
// Call for preparing the sample image element included the latest dynamically inserted
9-
loadingAttributePolyfill.prepareElement(this);
9+
loadingAttributePolyfillWithServiceWorker.prepareElement(this);
1010
}
1111
}
1212

dist/loading-attribute-polyfill-with-serviceworker.css

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/loading-attribute-polyfill-with-serviceworker.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/loading-attribute-polyfill-with-serviceworker.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/loading-attribute-polyfill-with-serviceworker.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/loading-attribute-polyfill-with-serviceworker.modern.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)