Search code examples
javascripthtmldokuwiki

Can I have a JavaScript in the header of a page that moves all other scripts just before the closing body tag?


I want to speed up the load of a Dokuwiki page by button the JavaScript-tags from the header into the bottom just before the closing body. Unfortunately the relevant scripts in there are created by template method of Dokuwiki that I cannot change and that will spill out all javascripts into the header (albeit condensed into one file).

Is it possible to write a Javascript that will the included script to the bottom of the page which I could integrate into the head just before the template method of Dokuwiki is loaded? Or does the execution order of HTML/Javascript prevent that, since the scripts are not yet visible when my script loads?


Solution

  • It would only be possible to move these scripts in the DOM once the DOM is loaded completely. So It would not speed up the pageload at all.

    But there are other ways to speed up your pageload time, like minifying resources if possible and minimizing the amount of required requests to the server.