Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 168

JavaScript is a dynamically-typed language commonly used for client-side scripting. Unless a tag for a framework/library is also included, a pure JavaScript answer is expected.

11 votes
Accepted

Add JavaScript with $doc->addScript with async="true"

If 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 … 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
Lodder's user avatar
  • 26.9k
7 votes
Accepted

Get access to php variable in Joomlas addscriptdeclaration for Javascript

Instantly see the issue here. What you basically doing is the following: <?php $var = 'foo'; <?php echo $foo; ?> ?> You're using duplicate <?php tags which will cause issues. Use t …
Lodder's user avatar
  • 26.9k
5 votes

Dynamic JS and CSS combining without JCH Optimize

JCH Optimize is one of those plugins where you should not simply select everything to be optimised and expect your site to be 2x faster in loading speeds. The more you try and optimise, the more proce …
Lodder's user avatar
  • 26.9k
5 votes
Accepted

Best Practice: Loading component Styles & Scripts in J4

If you're loading a single file that has no dependencies, then the Web Asset Manager has a lot of unecessary overhead and you're probably best off using HTMLHelper When it comes to Javascript, I never …
Lodder's user avatar
  • 26.9k
4 votes
Accepted

How can I add a local custom javascript file into the bottom of the template's index.php file?

It means a Javascript module which is deferred automatically. …
Lodder's user avatar
  • 26.9k
3 votes

Joomla $document->addScriptDeclaration with single quote and double quote

You need to escape the quotes using backwards slashes like so: // No direct access defined('_JEXEC') or die; //JHtml::addIncludePath(JPATH_COMPONENT.'helpers/html'); JHtml::_('behavior.tooltip'); JH …
Lodder's user avatar
  • 26.9k
3 votes

RokSprocket automate Load More

I've never used RokSprocket before but I hope this answer will help you. Lets say you have the following HTML markup for your button: <div class="loadmore">Load more</div> Now rather than actually …
Lodder's user avatar
  • 26.9k
3 votes
Accepted

CSS/JS compression distorts the website template/look

is, go to the Automatic Settings Group options, then: Disable all options under these settings Enable the options to minify CSS and JS Enable to option to combine CSS and JS Finally, enable the GZip JavaScript
Lodder's user avatar
  • 26.9k
3 votes
Accepted

iFrame with javascript

Firstly, your Javascript contains an error so it won't run at all. Specifically you're missing a ) near the end. … Just because you're loading the iframe source via Javascript, does not mean people won't be able to see the code. …
Lodder's user avatar
  • 26.9k
3 votes

What's the correct way of adding code after the start of the body tag?

If you don't want to edit the template's index.php file, then I'd suggest that you use a plugin and utilise JApplication to get and set the body. You can then use the following in your plugin: publi …
Lodder's user avatar
  • 26.9k
2 votes
Accepted

Jquery marquee script not working in joomla?

First thing's first: do not import an unofficial jQuery library forked by someone! Now, when importing any script, you should always define the root of your site using JUri::root(). You should also us …
Lodder's user avatar
  • 26.9k
2 votes

2.5 template/css issues: article links not working in Chrome, link colors locked globally to...

This is because your sidebar is overlapping the whole content area as it's width has been set to 90%. Go to line 180 of your main.css file and change the width to 18% The white links on the right sid …
Lodder's user avatar
  • 26.9k
2 votes
Accepted

Where to call for CSS/JS in custom component for frontend views

I'd suggest placing it in your view file: components/com_mycomponent/views/VIEW_NAME/tmpl/default.php This means that is anyone wishes to override your component views, they can, for example, re …
Lodder's user avatar
  • 26.9k
2 votes

best way to add third party js and css

Personally, I'd much rather deliver CSS and JS files via a CDN than using something like JCH optimise to combine them all into 1 file. With HTTP/2, files are delivered much quicker, so a couple more h …
Lodder's user avatar
  • 26.9k
2 votes
Accepted

What is the correct way to add Javascript as of Joomla 3.x?

So to answer you actual question, the correct way to add Javascript to your site will be as following: General: JFactory::getDocument()->addScriptDeclaration(' alert(1); // more Javascript here …
Lodder's user avatar
  • 26.9k

15 30 50 per page