@divriots/jampack 0.11.1 → 0.11.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,4 +1,7 @@
1
1
  const default_options = {
2
+ html: {
3
+ add_css_reset_as: 'inline',
4
+ },
2
5
  image: {
3
6
  embed_size: 1500,
4
7
  srcset_min_width: 640,
@@ -4,6 +4,9 @@ export type WebpOptions = {
4
4
  quality: number;
5
5
  };
6
6
  export type Options = {
7
+ html: {
8
+ add_css_reset_as: 'inline' | 'off';
9
+ };
7
10
  image: {
8
11
  embed_size: number;
9
12
  srcset_min_width: number;
package/dist/optimize.js CHANGED
@@ -79,13 +79,15 @@ async function analyse(file) {
79
79
  $('the-fold').remove();
80
80
  }
81
81
  // Add CSS to head
82
- const CSS = `<style>:where(img){height:auto;}</style>`;
83
- const heads = $('head');
84
- if (heads.length > 0) {
85
- heads.prepend(CSS);
86
- }
87
- else {
88
- (_a = $('html')) === null || _a === void 0 ? void 0 : _a.prepend(`<head>${CSS}</head>`);
82
+ if (config.html.add_css_reset_as === 'inline') {
83
+ const CSS = `<style>:where(img){height:auto;width:auto}</style>`;
84
+ const heads = $('head');
85
+ if (heads.length > 0) {
86
+ heads.prepend(CSS);
87
+ }
88
+ else {
89
+ (_a = $('html')) === null || _a === void 0 ? void 0 : _a.prepend(`<head>${CSS}</head>`);
90
+ }
89
91
  }
90
92
  if (!$state.args.nowrite) {
91
93
  await fs.writeFile(path.join($state.dir, file), $.html());
@@ -122,6 +124,13 @@ async function processImage(htmlfile, $, imgElement, isAboveTheFold) {
122
124
  */
123
125
  const attrib_src = img.attr('src');
124
126
  if (!attrib_src) {
127
+ const attrib_data_src = img.attr('data-src');
128
+ if (attrib_data_src) {
129
+ // Contains attribute [data-src]
130
+ // Most likely, this is a Javascript lazy-loaded image
131
+ // Let's not mess with it and hope it's well done
132
+ return; // No warnings
133
+ }
125
134
  $state.reportIssue(htmlfile, {
126
135
  type: 'warn',
127
136
  msg: `Missing [src] on img - processing skipped.`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divriots/jampack",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "Packer for static websites",
5
5
  "author": "Georges Gomes @georges-gomes",
6
6
  "bin": {