Socket
Book a DemoInstallSign in
Socket

document-height

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

document-height

Get the height of the document, across browsers.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

100% test coverage

document-height

Utility to return the height of the current document

Installation

Install via npm.

$ npm i document-height --save

Usage

Require and call as needed. Document height is cached, so there's likely no reason to hang on to the returned value within your implementation (except to save a function call). To clear the cache, you must pass a true parameter.

var docHeight = require('document-height');

// Assuming a 1000px tall document...
console.log(docHeight()); // logs 1000

// At some point the height of the document
// changes to 1500px - the module will still
// return its cached value of 1000
console.log(docHeight()); // logs 1000

// to re-measure, pass a truthy value
console.log(docHeight(true)); // logs 1500

Tests

Tests are mocha browser-based, and can be run via:

npm i && npm run build && npm test

A test coverage report can be generated via:

npm run coverage && open coverage/lcov-report/index.html

Keywords

document

FAQs

Package last updated on 29 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts