#attached supports external files, because drupal_add_js/css does.
But because drupal_process_attached mucks around quite a bit with the parameters it passes to the above functions it's not really trivial to see how it's done.
At least it took me about 2 hours and a nudge from sun...

Here's a patch that adds a bit of documentation including a code example.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

thx

Dries’s picture

Status: Reviewed & tested by the community » Needs work

I sounds like the verb 'be' is missing between 'also' and 'loaded'. The syntax is awkward but we'll work on that later.

jhodgdon’s picture

There also shouldn't normally be a blank line before the @code, since it's logically part of the same paragraph.

tstoeckler’s picture

Here you go. There was a newline before @code right above that so I removed that as well.

tstoeckler’s picture

Status: Needs work » Needs review

Setting to 'Needs review'.

sun’s picture

+++ includes/common.inc	12 Aug 2010 17:20:58 -0000
@@ -3918,13 +3918,22 @@ function drupal_get_js($scope = 'header'
+ * External files can also be loaded using the #attached syntax. Note that this

Since this is in the docs for #attached, we don't need to repeat "using the #attached syntax". Lastly, we can shorten the remaining:

"External files can also be loaded, but is restricted to the 'js' and 'css' types. For example:"

+++ includes/common.inc	12 Aug 2010 17:20:58 -0000
@@ -3918,13 +3918,22 @@ function drupal_get_js($scope = 'header'
+ * $build['#attached']['js'] = array(
+ *   'http://code.jquery.com/jquery-1.4.2.min.js' => array(
+ *     'type' => external',

That said, I find it very odd that url() detects external URLs and automatically handles them accordingly, but drupal_add_js/css() do not?

Powered by Dreditor.

tstoeckler’s picture

"External files can also be loaded, but is restricted to the 'js' and 'css' types. For example:" <- Sorry, but I'm pretty certain that's not correct English =)

jhodgdon’s picture

Status: Needs review » Needs work

status change as per #6. Note in #7 - is->are

tstoeckler’s picture

Status: Needs work » Needs review
FileSize
1.06 KB

Rerolled.

jhodgdon’s picture

Status: Needs review » Needs work

"but only the 'jss' and 'css' types. "
Should be 'js' not 'jss'

Also this patch is missing the drop-the-newline bit from the previous patch.

tstoeckler’s picture

Status: Needs work » Needs review
FileSize
764 bytes

The stray newline must have gotten lost in another commit. Anyway rerolled for 'jss' => 'js'.

jhodgdon’s picture

This looks OK to me. I'll let someone else who commented above set to RTBC though.

sun’s picture

+++ includes/common.inc	9 Nov 2010 18:31:03 -0000
@@ -4149,6 +4149,16 @@ function drupal_get_js($scope = 'header'
+ * External files can also be loaded, but only the 'js' and 'css' types. For

"but only the 'js' and 'css' types" works on its own, but as part of the full sentence, it reads somewhat incomplete.

Shouldn't that be "External files can also be loaded, but only FOR the ... types" ?

Overall, how about:

"External files can be loaded for type 'js' and 'css'. For example:"

Powered by Dreditor.

jhodgdon’s picture

only FOR the types?

Actually, that sounds worse to me.

How about: External CSS and JavaScript files can also be loaded. For example:

jhodgdon’s picture

FileSize
698 bytes

Here's a new patch. There was also a missing ' in the code example...

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Great!

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.