Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
9

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'] = $type; $this->_scripts[$url]['defer'] = $defer; $this->_scripts[$url]['async'] = $async; return $this; } $async is a boolean ...


9

It won't be easy to deal with all these files. Combining, minifying and compressing all these together will most probably bring issues. It will take much effort and a combination of techniques to reach a satisfactory optimization level. My overall Approach to achieve a fast loading site. A fast website is essential. The speed optimization of a website, ...


8

Joomla has a certain method for this. First, in view.html.php add all strings, what needs to be translated with this: JText::script('VALIDATION_ERROR'); This will add your string to javascript object, what you can use later. And in javascript, use: Joomla.JText._('VALIDATION_ERROR') Which will give you matching translation in current language. This way ...


7

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 the following instead <?php $document = JFactory::getDocument(); $variable = "test"; $document->addScriptDeclaration(' ...


7

First, according to the docs AdSense code doesn't go after the <head>, it goes between the <body> tags. JavaScript should almost always be placed at the end of the body, just before </body>, so slow-loading scripts don't hold up the rest of your page (in this case, however, the script is loaded asynchronously so that shouldn't be much of an ...


6

In Joomla, you can add scripts using JHtml::script or $doc->addScript, and if you add the same path twice, it will only get included once in the output <head>: JHtml::script("path/to/jquery.scrollTo.min.js"); This will not deduplicate the same script at different paths. Unfortunately, there is no built-in way to do this that I can see. For JQuery ...


6

The JDocument's addScript method has no options for ordering (eg by priority or something like WP). There are numerous ways to solve your problem. First, to understand why what you're doing is causing the problem you need to know the Joomla lifecycle. Bootstrap Framework & Application Route Component Modules Template Render and Respond So when you ...


5

JDocument->addScript() has options to defer the loading of the script and/or load it async. See the API doc: http://api.joomla.org/cms-3/classes/JDocumentHTML.html#method_addScript This will allow the browser to load the scripts later in the process, which will help with the pageload time. There is no API to load the scripts at the bottom of the page. If ...


5

Articles are for content, not source code. Rule of thumb, different content in different places. If I have to quickly include Javascript, I would recommend NoNumber Sourcerer: http://www.nonumber.nl/extensions/sourcerer DRY principle, don't repeat yourself. Create modules with the Javascript code, and include it with {loadposition module-position}


5

All the things mentioned by @Bakual are correct but I notice that you are just passing the result.message to alert and given that [alert(message)][1] expects message to be a string or an object it can convert to a string this could be the problem. If result.message is just a string, then you will need to wrap it in an appropriate container, something like ...


5

This answer is very long and has many methods, best is at the bottom unset($doc->_scripts[JUri::base(true)'/path/to/file.js']) is mostly how to do it, some scripts might add the full url and some might not. So here is a better way to go about it if you want everything removed. $doc->_scripts = array(); //if you need to re include libraries JHtml::_(...


5

There is no simple solution for 30+ JS files. Since you are onboard with Rockettheme, you can implement RokBooster http://www.rockettheme.com/joomla/extensions/rokbooster You can implement CloudFlare, or any other CDN. Ref: http://en.wikipedia.org/wiki/Content_delivery_network


5

You can inject system messages at any point in the page render cycle like so: JFactory::getApplication()->enqueueMessage('My glorious message','error'); The jdoc tag basically creates the place host and loads needed files required to inject and display messages. Hope this helps, but depending on exactly where you plan on creating message in code could be ...


5

It expects the messages to be passed in an array, even if there is only a single message, ie Joomla.renderMessages({"success":["this is test message"]}); The formatting example given in the source code for the renderMessages function (\media\system\js\core-uncompressed.js) is: var messages = { "message": ["Message one", "Message two"], "error": [...


4

It is the double quotes in the script/string. Try this: <?php $ReftaggerOut = " <script type='text/javascript'> var refTagger = { settings: { bibleVersion: ".$BibleTranslation." } }; (function(d, t) { var g = d.createElement(t), s = d.getElementsByTagName(t)[0];...


4

A simple way to introduce a Ajax is with Joomla Ajax Interface:. What is The Joomla Ajax Interface (com_ajax) A slim, extensible component to act as an entry point for HTTP requests for stand alone modules and plugins, thus allowing for the potential of Ajax functionality in them. Com_ajax is generally used when you are not the developer of the component ...


4

Your code has several errors, here's a couple: js.js You can't load scripts using <script> inside a .js file You shouldn't need to load jQuery at all, it's included in Joomla (and it's usually loaded by your template or other extensions). If not, use JHtml::_('jquery.framework'); to load it properly. This entire file looks unnecessary to me, as you'...


4

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 processing the plugin must do. You may also reach a point, where there is no room for more optimisation. What I would suggest you do first is only use JCH to ...


4

You need to trigger submit on form for login user. edit: did not see You don't have a login id in your div. so try this: jQuery('.loginbtn').trigger('click'); and if this not work for you try this: jQuery('.loginbtn').parents('form').submit();


4

You have either some files corrupted on update, or some outdated server software. Overwrite your web-site with Joomla 3.6.0 full package to be sure it's no a file corruption (extract the Joomla full package and upload everything except installation folder using overwrite). If this doesn't help, enable development error level and check the link. You'll see ...


4

I think there are at least 4 options. In gantry5 templates go extension>templates, select your template, and on the page settings tab there is a textbox labeled "Before </body>". This will be included on all frontend pages so if your need it only in some places you could use an assign a template outline. Use javascript to insert the script tag on ...


3

There are several ways to achieve this in Joomla: 1. You might want to take a look at a plugin called Sourcerer from NoNumber: Sourcerer enables you to place PHP and any kind of HTML style code (including CSS and JavaScript) right into your content! Not only in your articles, but also in sections, categories, modules, components, META tags, etc. ...


3

I Assume that your current html editor is TinyMCE. Go to Administrator -> Extensions -> Plugin Manager -> Editor - TinyMCE Delete the word script if it is listed in the "Prohibited Elements" field and save the plugin. Then create a new "Custom HTML Module" by Going to Administrator -> Extensions -> Module Manager -> +New -> Custom HTML Click on the ...


3

I realize you've solved the syntax error issue, but the right way to solve this problem is to not insert javascript with PHP this way. What you should be doing is: 1) create your javascript file in media/plg_yourplugin/js/your-js-file.js 2) in PHP use JHTML library API to add the javascript file to the index.php area. Here's a blog post by @Michael on ...


3

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'); JHtml::_('behavior.formvalidation'); JHtml::_('behavior.keepalive'); JHtml::_('bootstrap.framework'); $document = JFactory::getDocument(); $document->...


3

If you're including the JavaScript as a user and customized to your article, then it's fine. Especially if it is different for each article. However if you happen to repeat the same JavaScript code in multiple articles, then there may be better solutions like an alternative article layout. You can read more about alternative layouts here: http://docs....


3

Should javascript not be included via joomla articles? If yes, why? I would advise gently against using JS straight up in articles... Not user-friendly - many editors will wipe out JS written inline (maybe not when you're using it, but when your lower-permission users do who aren't allowed to save articles with code in them...) Can't combine / minify (...


3

Ok one thing with Joomla is never use the $ character for jQuery without making sure it is not conflicting with mootools. Joomla has gotten better but its best to just use jQuery rather then $ in my opinion. Its far less stressful then the other ways. Also I assume the HTML loads fine? just no Javascript? Here are some thoughts to help with that: $(...


3

The other way to do it, and the method that I prefer, is to simply create an override for the extension and comment out the call for the script there. I do this all the time, for almost every extension I use, removing both script and css calls. The only possible gotcha is that if the extension developer did not put the calls in the view file, then you can'...


3

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 hiding the element, you make it transparent instead using CSS: .loadmore { opacity: 0; } And as for the auto load, you can trigger a click ...


Only top voted, non community-wiki answers of a minimum length are eligible