Skip to content

Commit

Permalink
Merge branch 'devel' into analyze-image
Browse files Browse the repository at this point in the history
  • Loading branch information
macbre authored Sep 18, 2023
2 parents 936a29c + 5e2f929 commit fff47d3
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 136 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
DOCKER_TAG: ghcr.io/macbre/phantomas:latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# https://github.com/marketplace/actions/build-and-push-docker-images
- name: Build the Docker image with ${{ env.DOCKER_TAG }} tag
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
tags: ${{ env.DOCKER_TAG }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20.x
node-version: latest
cache: npm

- name: Install dependencies
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ jobs:
npm-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

#
# https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-npm
#
- uses: actions/setup-node@v3
with:
node-version: '14.x'
node-version: 'latest'
registry-url: 'https://npm.pkg.github.com'

# GitHub Packages only supports scoped npm packages.
Expand All @@ -38,7 +38,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: '14.x'
node-version: 'latest'
registry-url: 'https://registry.npmjs.org'

- name: Publish to npm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-to-ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: "ubuntu-20.04"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build and publish a Docker image for ${{ github.repository }}
uses: macbre/push-to-ghcr@master
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
fail-fast: false
matrix:
# https://github.com/nodejs/release#release-schedule
# https://github.com/actions/setup-node#supported-version-syntax
node-version:
- '16.x'
- '18.x'
- '20.x'
- "lts/*"
- "latest"

services:
# https://github.com/postmanlabs/httpbin
Expand All @@ -31,13 +31,16 @@ jobs:
- "5555:80"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
cache: npm
node-version: ${{ matrix.node-version }}

- name: Log the Node.js version used
run: echo "::notice::Using Node.js $( node -v)"

- name: Install dependencies
run: npm ci

Expand Down Expand Up @@ -79,7 +82,7 @@ jobs:
# upload coverage report for just one of Node.js version matrix runs
- name: Upload coverage report to Coveralls
if: matrix.node-version == '16.x'
uses: coverallsapp/[email protected].1
uses: coverallsapp/[email protected].3
continue-on-error: true
with:
github-token: ${{ github.token }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/upgrade-puppeteer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ jobs:
steps:
# https://github.com/actions/checkout
- name: Cloning ${{ env.GIT_BRANCH }} branch
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_BRANCH }}

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: latest

- name: Install dependencies and try to bump puppeteer
run: |
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
--label 'external dependency' \
--base ${{ env.GIT_BRANCH }} \
--title "bump puppeteer to v${VERSION}" \
--body "[Release notes](https://github.com/puppeteer/puppeteer/releases/tag/v${VERSION})"
--body "[Release notes](https://github.com/puppeteer/puppeteer/releases/tag/puppeteer-v${VERSION})"
# e.g. https://github.com/macbre/analyze-css/pull/443
export PR_URL=$(gh pr view ${PR_BRANCH} --json url | jq -r .url)
Expand Down
8 changes: 7 additions & 1 deletion modules/lazyLoadableImages/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
len = images.length,
offset,
path,
native,
processedImages = {},
src,
viewportHeight = window.innerHeight;
Expand All @@ -30,6 +31,9 @@
// @see https://stackoverflow.com/questions/35586728/detect-used-srcset-or-picture-tag-source-with-javascript
src = images[i].currentSrc;

// Chrome headless loads images with native lazyloading, therefore we need to filter by ourself.
native = images[i].loading === "lazy";

// ignore base64-encoded images
if (src === null || src === "" || /^data:/.test(src)) {
continue;
Expand All @@ -42,6 +46,7 @@
processedImages[src] = {
offset: offset,
path: path,
native: native,
};
}

Expand All @@ -50,6 +55,7 @@
processedImages[src] = {
offset: offset,
path: path,
native: native,
};
}
}
Expand All @@ -62,7 +68,7 @@
Object.keys(processedImages).forEach((src) => {
var img = processedImages[src];

if (img.offset > viewportHeight) {
if (img.offset > viewportHeight && !img.native) {
phantomas.log(
"lazyLoadableImages: <%s> image (%s) is below the fold (at %dpx)",
src,
Expand Down
Loading

0 comments on commit fff47d3

Please sign in to comment.