News:

Dear forum visitors, if the support forum is not available, please try again a few minutes later. Thanks!

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 2 Guests 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
  •