Using CDN links in a Custom HTML Prompt?

Continuing the discussion from Keyboard Maestro and JSX:

I see you’re doing this in your Custom HTML Prompt:

<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js'></script>

The only reasons why I haven’t done this up until now is because I was worried what would happen if the user doesn’t have Internet connection.

I realize these days that doesn’t happen much, but a couple of months ago I was working somewhere without connectivity, and I had a few issues with other apps, so I was worried.

It’s probably not an issue because there’s probably a cache, except I’m not positive the cache persists when using HTML in KM.

Any thoughts?

Hey Dan,

Requiring an Internet connection to do a dialog is a no, no as far as I’m concerned.

I don’t like anything accessing the Net behind my back (so to speak).

-Chris

Hadn't thought about it that way, but it's a good point. I don't think I personally care, in this instance, but I can certainly imagine some people caring, yourself obviously included.

Thanks for the input.

I totally agree with you guys but this macro was mostly an experiment and I made it for my personal use only. I provided it in this forum as an example of what can be achieved with SVG and jQuery in a Custom HTML Prompt

If I had to make a macro that should be distributed for the masses, I probably would join the jQuery library within a macro folder and I would use a relative link to avoid the need of an internet connection. But we should add a variable for this relative link and ask people to update it to set the root to the jQuery library.

As recommended by @iNik in the following topic:

A little bit more complex than a direct link in my case.

I understand you were doing it for yourself, and I didn’t mean to be critical. It’s just that seeing how you used it, I thought I’d put the question out there.

I’ve written and uploaded multiple macros that do exactly what you suggested. I’ve got code that the macro can use to make sure it knows where its “resources” folder is, and all of that kind of stuff. I’m not suggesting you need it, but perhaps someone will, so I suppose I should upload a demo.

No worries Dan,

I do not take this badly. We are here to discuss, read different points of view and use them to make better macros. Appreciate your input.

1 Like

It’s worth considering just running a webserver on localhost for this kind of thing. Not for anything you are publishing, but for personal hacks. Once you have a little server that’s always running, there’s tons of other small things it can be used for.

1 Like

Hey Carl,

How about providing some more specific examples and a recommendation for the server software.

-Chris

I personally use Bottle or CherryPy, just because I’m most comfortable writing servers in Python. You can use anything though.

Whenever I ran a server like this, I mainly used it to host JS libraries at paths I could easily remember, like /static/jquery.js, and to keep often needed code and data in memory. For example, scripts that provide output for the tmux status bar can be converted to request handlers to save firing up an interpreter and reading a script and its deps from disk once every second.

Mac comes with Apache 2 / PHP built in. I think MySQL as well.

Almost the first thing I did when moving work machine from RHEL to MacBook Pro the other day was move my localhost stuff to work with the built in Apache 2 / PHP setup.

1 Like