DocumentService (jQuery.ready substitute)
The module TYPO3/
provides native JavaScript
functions to detect DOM ready-state returning a Promise<Document>
.
Internally the Promise is resolved when native DOMContent
event has
been emitted or when document.
is defined already. It means
the initial HTML document has been completely loaded and parsed, without
waiting for stylesheets, images, and sub-frames to finish loading.
$(document).ready(() => {
// your application code
});
Copied!
Above jQuery code can be transformed into the following using Document
:
import DocumentService from '@typo3/core/document-service.js';
DocumentService.ready().then(() => {
// your application code
});
Copied!