Jump to content

Is Javascript only supported in yosemite or something?


Maddog

Recommended Posts

Just got the Alfred 2.8 update. I see javascript as an option for scripting, but when I try to debug a simple script, this is what I get in the debug:

 

[alfred.workflow.action.script] osascript: no such component "JavaScript".

 

Also, searching for "javascript" doesn't work in the forums, it gets filtered out, probably due to XSS concerns.

 

Thanks for any guidance.

 

My OSX version is 10.9.5.

 

EDIT: oops, missed the fact that it's for 10.10+ :( How do I delete this thread?

Edited by Maddog
Link to comment

Do you know if there'll be support for AJAX (XHR) requests at some point? 

 

I'd say that it never will. Andrew tries to keep the size of Alfred small so that it keeps performing quickly. In order to do something like AJAX, he'd have to compile in all or part of a JS rendering engine (95% of which wouldn't apply to Alfred).

 

What would you use the Ajax for with Alfred, anyway? Updating script filter results?

Link to comment

I'd say that it never will. Andrew tries to keep the size of Alfred small so that it keeps performing quickly. In order to do something like AJAX, he'd have to compile in all or part of a JS rendering engine (95% of which wouldn't apply to Alfred).

 

What would you use the Ajax for with Alfred, anyway? Updating script filter results?

 

Yeah. I'd simply like to call an API, get the data, and show them in the results.

I used the Node.js workflow template previously, but I was stoked to see JS support in Alfred – but not very useful for me without the ability to call APIs.

Link to comment

Yeah. I'd simply like to call an API, get the data, and show them in the results.

I used the Node.js workflow template previously, but I was stoked to see JS support in Alfred – but not very useful for me without the ability to call APIs.

 

You can still call APIs and get the data and all that jazz, but you just have to do it synchronously rather than asynchronously. So, make sure that you get the data before you render any XML for a script filter.

Link to comment

You want to look into the Apple JavaScript scripting API.

 

This has nothing to do with Alfred: it just provides access to the JavaScript scripting engine as provided by OS X.

 

As Shawn says, there isn't a chance in hell that Andrew will include something like Node in Alfred: Node.js is well over 5 times the size of Alfred. That's a rotten payoff for including a crappy language.

 

There's also very limited benefit in any kind of async jazz (unless you need to download multiple things at once), as workflows are entirely synchronous. You might be able to perform async queries, but you'll have to wait for the results and tie them all together in a decidedly synchronous fashion before sending any results to Alfred.

Link to comment

As the others have pointed out, the Javascript supported is the Javascript API that is built into OSX and not Javascript based on a specific runtime like Node.js or io.js. Alfred only provides built in support for languages that come preinstalled within OSX which eliminates things like Node.js and io.js. You could still create workflows to use node by setting your environment within the code area of a Run Script like this:

/usr/local/bin/node <<-'CODE'
var temp = require('underscore')
console.log('testing this')
CODE
Edited by deanishe
supposed -> supported
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...