Skip to content

Latest commit

 

History

History
82 lines (61 loc) · 1.38 KB

README.md

File metadata and controls

82 lines (61 loc) · 1.38 KB

SimpleAsyncLoaderJS

DE - Führe einfach die Funktionen von async geladenen JavaScript Dateien aus


EN - Just execute the functions of async loaded JavaScript files


Example html

<!doctype html>
<html lang="en">
<head>
    <title>SimpleAsyncLoaderJS</title>
    <script src="SimpleAsyncLoaderJS.js" async></script>
    <script src="my-script.js" async></script>
</head>
<body>
</body>
</html>

Example asyncFunctions array

if (typeof asyncFunctions === "undefined") {
   var asyncFunctions = [];
}
asyncFunctions.push(function() {
    console.log('called')
});

Example data-script-function.js

function dataScriptFunction() {
    console.log('example-data-script called', document.getElementById('element'));
}
<script src="data-script-function.js" async data-script-function="dataScriptFunction"></script>

Usage CMS Contao >4.9

https://contao.org/

  1. Install agentur1601com/file-lazy-loader
$ composer require agentur1601com/file-lazy-loader
  1. Go to Themes -> Page layout -> FileLazyLoader - JS

  2. Load your JavaScript files async


@Author: Lukas Beck

@Email: lb@1601.com

@Link: https://github.com/LBeckX

@Copyright 1601.communication gmbh

@Link: https://www.1601.com

@Link: https://github.com/1601com

@Support: support@1601.com