Giter VIP home page Giter VIP logo

domcontentloaded's Introduction

DOMContentLoaded

fixing the (in)famous event that does not trigger once "loaded".

Please read the post to know more about issues you might have relying this event.

How To

Simply include the inline version of the script on top of any of your HTML pages (few extra bytes, really nothing to worry about) and stop worrying about not being initialized once the DOM Content ... has been Loaded !!!

Can you believe it ?

Content Security Policy

If you are under this restriction, here the deprecated sha1 version of the script: sha1-//cbZaIlYySeh0GGSwpZKzOAkvg=

While if you are targeting modern browsers, here the sha256 version: sha256-XpSHSiwcWV9TTNd43i/nMFtZA8u8gQVfVXEy6Wa68a0=

These digests have been tested without problems via server side headers, as well as meta tag:

<meta
  http-equiv="Content-Security-Policy"
  content="script-src 'unsafe-inline' 'self' 'sha1-//cbZaIlYySeh0GGSwpZKzOAkvg=' 'sha256-XpSHSiwcWV9TTNd43i/nMFtZA8u8gQVfVXEy6Wa68a0='"
>

Bear in mind you must specify 'unsafe-inline' in addition to 'self' for backward compatibility.

Example

Just try to write something like:

document.addEventListener('DOMContentLoaded', function (e) {
  alert([e.type, e.currentTarget === document]);
});

in this page console and you should have your always notified DOMContentLoaded event.

domcontentloaded's People

Contributors

webreflection avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

domcontentloaded's Issues

Chrome: Uncaught RangeError

Chrome is throwing an

Uncaught RangeError: Maximum call stack size exceeded.

For this line:

document[add] = function addEventListener(

when I try to add another EventListener like this one:

document.addEventListener('touchmove', jPar.navi.scroll.doScroll, false);

Anything I can do?

Publish to npm?

Hi,
this script has made my life so much easier and I now start almost every new project by including it. Thanks a lot for the effort!

It would be nice to be able to include it as a project dependency from npm instead of copying it all over. Would you mind adding a package.json and publish to npm?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.