@divriots/jampack 0.30.1 → 0.30.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ //import { Options } from './config-types.js';
1
2
  const fast_options_override = {
2
3
  image: {
3
4
  embed_size: 0,
package/dist/optimize.js CHANGED
@@ -41,7 +41,7 @@ async function analyse(state, file) {
41
41
  const imgElement = imgsArray[i];
42
42
  spinnerImg.text = kleur.dim(`<img> [${i + 1}/${imgsArray.length}] ${$(imgElement).attr('src')}`);
43
43
  const img = $(imgElement);
44
- const isAboveTheFold = isImgAboveTheFold(img, imgElement, theFold);
44
+ const isAboveTheFold = isElementAboveTheFold(img, imgElement, theFold);
45
45
  img.removeAttr(ABOVE_FOLD_DATA_ATTR);
46
46
  try {
47
47
  await processImage(state, file, img, isAboveTheFold);
@@ -75,7 +75,9 @@ async function analyse(state, file) {
75
75
  for (let i = 0; i < iframesArray.length; i++) {
76
76
  const ifElement = iframesArray[i];
77
77
  spinnerIframe.text = kleur.dim(`<iframe> [${i + 1}/${iframesArray.length}] ${$(ifElement).attr('src')}`);
78
- const isAboveTheFold = ifElement.startIndex < theFold;
78
+ const ifr = $(ifElement);
79
+ const isAboveTheFold = isElementAboveTheFold(ifr, ifElement, theFold);
80
+ ifr.removeAttr(ABOVE_FOLD_DATA_ATTR);
79
81
  try {
80
82
  await processIframe(file, $, ifElement, isAboveTheFold);
81
83
  }
@@ -167,14 +169,14 @@ async function analyse(state, file) {
167
169
  await fs.writeFile(path.join(state.dir, file), htmlResult);
168
170
  }
169
171
  }
170
- function isImgAboveTheFold(img, imgElement, theFold) {
171
- const aboveTheFoldAttr = img.attr(ABOVE_FOLD_DATA_ATTR);
172
+ function isElementAboveTheFold(cheerio, element, theFold) {
173
+ const aboveTheFoldAttr = cheerio.attr(ABOVE_FOLD_DATA_ATTR);
172
174
  if (aboveTheFoldAttr) {
173
175
  const parsed = parseInt(aboveTheFoldAttr);
174
176
  if (!Number.isNaN(parsed))
175
177
  return !!parsed;
176
178
  }
177
- return imgElement.startIndex < theFold;
179
+ return element.startIndex < theFold;
178
180
  }
179
181
  function getTheFold($) {
180
182
  const theFolds = $('the-fold');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divriots/jampack",
3
- "version": "0.30.1",
3
+ "version": "0.30.2",
4
4
  "cache-version": {
5
5
  "img": "v1",
6
6
  "img-ext": "v1"