🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

delay-script

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

delay-script

Delay Loading of Non Critical Scripts

latest
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

delay-script ⚡

Delay Loading of Non Critical Scripts

Features

  • Downloads all delayed scripts in parallel
  • Execute scripts in order they appear in html
  • Supports delaying Inline scripts as well
  • tiny 495 bytes

Setup

  • Include dist/delay-script.min.js code in your page
  • Set type="text/delay" on the scripts you wish to delay
  • Call loadDelayScripts when you want to load all the delay scripts

Example

View Example HTML

<script type="text/delay" src="foo.js"></script>
<script type="text/delay" src="bar.js"></script>
...
// load delay-scripts after load event is fired
window.addEventListener('load', () => {
	loadDelayScripts(() => {
		console.log('done');
	});
});

API

// loads the delay scripts
loadDelayScripts();

// loads the delay scripts and calls fn when all are delay scripts are loaded and executed
loadDelayScripts(fn);

Keywords

delay-script

FAQs

Package last updated on 29 Jan 2022

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