nomadjimbob / mikio

Customizable, Bootstrap 4 inspired template for Dokuwiki
GNU General Public License v2.0
23 stars 6 forks source link

Add support for deferred JavaScript #39

Closed cmacmackin closed 2 years ago

cmacmackin commented 2 years ago

Currently, all JavaScript from this template is always loaded immediately (without the defer attribute). This can have a negative impact on performance. It also means that, should it depend on any JavaScript from the core DokuWiki and defer_js is turned on, it can break. Therefore, this pull request modifies the code inserting the JavaScript so it will check whether defer_js is true and act accordingly.

nomadjimbob commented 2 years ago

From what I can see, the defer attribute is always set to defer regardless, even if a site admin changes the defer_js option to false.

I also think this may break under Greebo as I don't think the key defer_js under $conf exists, so may need to have a case therefor

Sorry if I've missed something, I'm only on mobile for the next few days.

I'm happy to add the version checks once I'm back in front of a computer.

cmacmackin commented 2 years ago

From what I can see, the defer attribute is always set to defer regardless, even if a site admin changes the defer_js option to false.

I don't think so, unless I did something seriously wrong.

I also think this may break under Greebo...

Ah, probably, yes. This was just something I wrote and tested on my own installation (Hogfather). Still very new to developing for DokuWiki.

nomadjimbob commented 2 years ago

I don't think so, unless I did something seriously wrong.

You're right. I didn't see that line 151 in mikio.js ('defer' => 'defer') was removed. It looked like defer was set there as well as within the $conf['defer_js'] block.

I will merge this when I'm back in a day or 2 and add the Greebo support straight afterwards.

That will then bring #40 into scope which I don't see would be a problem.

Thanks for your PRs