- This topic is empty.
October 23, 2015 at 6:48 am #210085EvaParticipant
The site i am working with, is joomla platform. I have tried with the extensions of joomla, but nothing good at all. Any method how to do this manually for those .js files ?
I tried to implement this piece of code in head.php file :
$ex_src = explode(“/”,$strSrc);
$js_file_name = $ex_src[count($ex_src)-1];
$js_to_ignore = array(“mootools-core.js”,”mootools-more.js”,”core.js”,”other files i had to defer”);
if( in_array($js_file_name,$js_to_ignore) AND substr_count($document->baseurl,”/administrator”) < 1 AND $_GET[‘view’] != ‘form’)
but this one stops those files from loading automatically.
Thank you !October 23, 2015 at 8:24 am #210088ShikkedielParticipant
I’ve been using the
asyncattribute on script tags for it here and there but you gotta beware what scripts you use it on. The jQuery library itself for example can’t have this, it has to be loaded synchronously for any other scripts using it to be executed correctly. But external scripts that are not intertwined will get a loading speed advantage from it, all loading together instead of one at a time.
Not much more I can offer on the subject myself…January 7, 2016 at 12:44 pm #236495ShikkedielParticipant
I’ve been messing around on my own pages with this and came to the conclusion that the
deferattribute is a much better option. Using
asyncseems to break document ready with jQuery and is unpredictable for the rest unless it’s a script that could be executed at any time. Instead of just putting the script links in the
<head>section (where I like them for overview) and making them render block the rest of the page, giving them the
deferattribute seems to work much better. It will have the same effect as putting all links at the bottom of the page. Google PageSpeed seems to like it a lot in any case.
<script defer src=" ... "></script>
Good support as well.
Deferring all scripts that depend on each other, will make them execute in the correct order.August 13, 2018 at 1:28 am #275278asdeideasParticipant
- You must be logged in to reply to this topic.