public function addScript($url, $type = "text/javascript", $defer = false, $async = false)
The above is the function call for JDocument. We encounter problems all the time with Cloudflare not liking some Javascript and we use the following to push our javascript:
$doc = JFactory::getDocument();
$doc->addScript( 'path/to/javascript.js' );
It would be nice to have the ability to add attributes so that we can do something like the following:
$doc->addScript( 'path/to/javascript.js', array( 'data-cfasync="false"');
So that could print out the following:
This would allow Cloudflare to bypass using it's rocket loader on the javascript file that we know it is having a rough time with.
This would also help with many other things besides cloudflare - but this is just an example.
@spignataro By the way you should always use JHtml::_('script', '/whatever.js'); and not addScriptDeclaration()
@spignataro rearranging the flags CANNOT happen in 3.x for B/C reasons
Also addScript() is NOT overridable so you are making things hard for others, not a good thing!
Good point.
| Labels |
Added:
?
|
||
| Status | New | ⇒ | Closed |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-04-13 07:25:47 |
| Closed_By | ⇒ | brianteeman |
Closed as stated above.
Pull requests are welcome
On 18 February 2016 at 20:45, spignataro notifications@github.com wrote:
Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/