The initialization of this script assumes the document.DomContentLoaded or window.load events will fire after it has been loaded, never before. I think this is supposed to be true if this is included as a <script> element in the HTML (barring old browsers), but it does not work if this script is dynamically added, such as with WebPack chunks, AMD or other loader mechanisms. This is useful if you want to only include the polyfill where you actually have date input types.
The fix is very basic, just first check if the document is already loaded and either initialize right away or add the event listeners.
The initialization of this script assumes the document.DomContentLoaded or window.load events will fire after it has been loaded, never before. I think this is supposed to be true if this is included as a
<script>
element in the HTML (barring old browsers), but it does not work if this script is dynamically added, such as with WebPack chunks, AMD or other loader mechanisms. This is useful if you want to only include the polyfill where you actually have date input types.The fix is very basic, just first check if the document is already loaded and either initialize right away or add the event listeners.