?
avatar spignataro
spignataro
18 Feb 2016

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.

avatar spignataro spignataro - open - 18 Feb 2016
avatar brianteeman
brianteeman - comment - 18 Feb 2016

Pull requests are welcome

On 18 February 2016 at 20:45, spignataro notifications@github.com wrote:

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.


Reply to this email directly or view it on GitHub
#9153.

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/

avatar dgt41
dgt41 - comment - 18 Feb 2016

It's already PR'd and waiting for merging #8540

avatar dgt41
dgt41 - comment - 18 Feb 2016

@spignataro By the way you should always use JHtml::_('script', '/whatever.js'); and not addScriptDeclaration()

avatar spignataro
spignataro - comment - 18 Feb 2016

@dgt41

I would recommend moving attribs to the beginning as putting in false, false, false, true, attrib() since that would just be programming long hand.

Also I am not using addScriptDeclaration() - we are using addScript()

avatar dgt41
dgt41 - comment - 18 Feb 2016

@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!

avatar spignataro
spignataro - comment - 18 Feb 2016

Good point.

avatar brianteeman
brianteeman - comment - 18 Feb 2016

In light of above comments about changes and the availability of #8540 which is in need of tests are you ok with me closing this one.

Remember without tests #8540 will not be considered for merging

avatar brianteeman brianteeman - change - 24 Feb 2016
Labels Added: ?
avatar brianteeman brianteeman - change - 13 Apr 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-04-13 07:25:47
Closed_By brianteeman
avatar brianteeman
brianteeman - comment - 13 Apr 2016

Closed as stated above.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9153.

avatar brianteeman brianteeman - close - 13 Apr 2016

Add a Comment

Login with GitHub to post a comment