News:

Support for jDownloads 3 has been ended
Since 17 August 2023 Joomla.org has discontinued support for Joomla 3.x. Therefore, we will no longer offer official support for our Joomla 3 jDownloads version 3.9.x from January 2024.
Please update your website to the latest Joomla version (Joomla 4 or Joomla 5) as soon as possible. Afterwards, please update jDownloads to the latest published version. The longer you delay, the more difficult the upgrade process for your website is likely to be.

Main Menu
Support-Forum

Asynchronous loading of CSS and JS

Started by Nyx, 24.06.2015 09:46:18

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nyx

Hi,

@ Arno:

Have you ever think about the asynchronous loading of the CSS and the JS?
In the moment the JS and CSS files block the loading of the web page.

paralellels load will help to Speedup the page load.
e.g .:

Async html code:

<script src = "demo_async.js" async> </ script>


or your code / joomla php

$document->addScript(JURI::base().'components/com_jdownloads/assets/js/jdownloads.js');


Async code code / joomla php:
$document->addScript(JURI::base().'components/com_jdownloads/assets/js/jdownloads.js','text/javascript" defer="false" async="true');


or this way:

QuoteIf you have a look at the Joomla addScript function, it shows the following:

public function addScript($url, $type = "text/javascript", $defer = false, $async = false)
{
    $this->_scripts[$url]['mime'] = $type;
    $this->_scripts[$url]['defer'] = $defer;
    $this->_scripts[$url]['async'] = $async;

    return $this;
}
$async is a boolean therefore the following should work for you:

$doc->addScript('//myscript.js', 'text/javascript', false, true);
The false is for $defer and true is for $async
http://joomla.stackexchange.com/questions/4035/add-javascript-with-doc-addscript-with-async-true



It's about these links / files in your code:

/com_jdownloads/assets/js/jdownloads.js
/com_jdownloads/assets/rating/js/ajaxvote.js
/com_jdownloads/lightbox/lightbox.js

/com_jdownloads/assets/css/jdownloads_buttons.css
/com_jdownloads/assets/css/jdownloads_fe.css
/com_jdownloads/assets/css/jdownloads_custom.css
/com_jdownloads/assets/rating/css/ajaxvote.css
/com_jdownloads/lightbox/lightbox.css

you can test this, for example here:
https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fwww.jdownloads.com%2Findex.php%3Foption%3Dcom_jdownloads%26view%3Dviewcategories%26Itemid%3D133&tab=desktop
  •