We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Best way to handle inline JS that depends on framework loaded in footer?

Erin Dalzell March 28, 2015 by Erin Dalzell

I am playing around with getting Stripe and Raven working together and have something working.

But I was thinking about how to make it into a plugin to make it easier for everyone else. However I have a problem.

To make it work, I need inline JS in my form:

  {{ raven:form formset="cookies" }}

  {{ /raven:form }}

Normally I load all my JS at the bottom of the file. But when I put the Stripe library (which requires jQuery) at the bottom I get an 'undefined $' error for the first line of the script (it can't find jQuery).

I don't want to put it all in the footer, because that's common across my site and I don't want that JS on all my pages, just the one with the order form. And I don't want to load multiple copies of jQuery because that's just dumb. I was hoping to write a plugin that one could put in one's form as that makes sense to me (including it where it's relevant), but that doesn't work.

I feel like there's a nice answer to this but I've been unable to come up with a good solution.


p.s. I did find this but that seems like overkill?

>>>>>>> Unanswered <<<<<<<
5 Replies